@@ -84,18 +84,6 @@ func BenchmarkLinearSearch_BulkLookups(b *testing.B) {
8484 }
8585}
8686
87- func BenchmarkTrie_BulkLookups (b * testing.B ) {
88- trie := newPrefixTrie ()
89- trie .InsertAll (benchmarkPrefixes )
90- b .ResetTimer ()
91-
92- for i := 0 ; i < b .N ; i ++ {
93- for _ , testStr := range benchmarkTestStrings {
94- _ = trie .HasPrefix (testStr )
95- }
96- }
97- }
98-
9987func BenchmarkSegmentTrie_BulkLookups (b * testing.B ) {
10088 trie := newSegmentPrefixTrie ()
10189 trie .InsertAll (benchmarkPrefixes )
@@ -121,17 +109,6 @@ func BenchmarkLinearSearch_SingleLookup_EarlyMatch(b *testing.B) {
121109 }
122110}
123111
124- func BenchmarkTrie_SingleLookup_EarlyMatch (b * testing.B ) {
125- trie := newPrefixTrie ()
126- trie .InsertAll (benchmarkPrefixes )
127- testStr := "cloud.google.com/go/storage/internal"
128- b .ResetTimer ()
129-
130- for i := 0 ; i < b .N ; i ++ {
131- _ = trie .HasPrefix (testStr )
132- }
133- }
134-
135112func BenchmarkSegmentTrie_SingleLookup_EarlyMatch (b * testing.B ) {
136113 trie := newSegmentPrefixTrie ()
137114 trie .InsertAll (benchmarkPrefixes )
@@ -156,17 +133,6 @@ func BenchmarkLinearSearch_SingleLookup_NoMatch(b *testing.B) {
156133 }
157134}
158135
159- func BenchmarkTrie_SingleLookup_NoMatch (b * testing.B ) {
160- trie := newPrefixTrie ()
161- trie .InsertAll (benchmarkPrefixes )
162- testStr := "example.com/mycompany/internal/service"
163- b .ResetTimer ()
164-
165- for i := 0 ; i < b .N ; i ++ {
166- _ = trie .HasPrefix (testStr )
167- }
168- }
169-
170136func BenchmarkSegmentTrie_SingleLookup_NoMatch (b * testing.B ) {
171137 trie := newSegmentPrefixTrie ()
172138 trie .InsertAll (benchmarkPrefixes )
@@ -187,14 +153,6 @@ func BenchmarkLinearSearch_Construction(b *testing.B) {
187153 }
188154}
189155
190- func BenchmarkTrie_Construction (b * testing.B ) {
191- b .ResetTimer ()
192- for i := 0 ; i < b .N ; i ++ {
193- trie := newPrefixTrie ()
194- trie .InsertAll (benchmarkPrefixes )
195- }
196- }
197-
198156func BenchmarkSegmentTrie_Construction (b * testing.B ) {
199157 b .ResetTimer ()
200158 for i := 0 ; i < b .N ; i ++ {
@@ -216,18 +174,6 @@ func BenchmarkLinearSearch_LookupAllocations(b *testing.B) {
216174 }
217175}
218176
219- func BenchmarkTrie_LookupAllocations (b * testing.B ) {
220- trie := newPrefixTrie ()
221- trie .InsertAll (benchmarkPrefixes )
222- testStr := "github.com/test/package/internal"
223- b .ResetTimer ()
224- b .ReportAllocs ()
225-
226- for i := 0 ; i < b .N ; i ++ {
227- _ = trie .HasPrefix (testStr )
228- }
229- }
230-
231177func BenchmarkSegmentTrie_LookupAllocations (b * testing.B ) {
232178 trie := newSegmentPrefixTrie ()
233179 trie .InsertAll (benchmarkPrefixes )
@@ -240,21 +186,6 @@ func BenchmarkSegmentTrie_LookupAllocations(b *testing.B) {
240186 }
241187}
242188
243- // Concurrent access benchmark
244-
245- func BenchmarkTrie_Parallel (b * testing.B ) {
246- trie := newPrefixTrie ()
247- trie .InsertAll (benchmarkPrefixes )
248- testStr := "cloud.google.com/go/storage/internal"
249- b .ResetTimer ()
250-
251- b .RunParallel (func (pb * testing.PB ) {
252- for pb .Next () {
253- _ = trie .HasPrefix (testStr )
254- }
255- })
256- }
257-
258189// Data structure memory overhead comparison
259190// This measures the memory cost of the data structure itself, not lookup allocations
260191
@@ -274,21 +205,6 @@ func BenchmarkDataStructureMemoryOverhead(b *testing.B) {
274205 m2 .Alloc - m1 .Alloc , len (benchmarkPrefixes ))
275206 })
276207
277- b .Run ("Trie_DataStructure" , func (b * testing.B ) {
278- var m1 , m2 runtime.MemStats
279- runtime .GC ()
280- runtime .ReadMemStats (& m1 )
281-
282- trie := newPrefixTrie ()
283- trie .InsertAll (benchmarkPrefixes )
284-
285- runtime .GC ()
286- runtime .ReadMemStats (& m2 )
287- b .ReportMetric (float64 (m2 .Alloc - m1 .Alloc ), "bytes_overhead" )
288- b .Logf ("Character trie data structure overhead: %d bytes for %d prefixes" ,
289- m2 .Alloc - m1 .Alloc , len (benchmarkPrefixes ))
290- })
291-
292208 b .Run ("SegmentTrie_DataStructure" , func (b * testing.B ) {
293209 var m1 , m2 runtime.MemStats
294210 runtime .GC ()
@@ -308,21 +224,13 @@ func BenchmarkDataStructureMemoryOverhead(b *testing.B) {
308224// Test correctness - ensure all implementations return the same results
309225func TestImplementationConsistency (t * testing.T ) {
310226 linear := newLinearPrefixMatcher (benchmarkPrefixes )
311- charTrie := newPrefixTrie ()
312- charTrie .InsertAll (benchmarkPrefixes )
313227 segmentTrie := newSegmentPrefixTrie ()
314228 segmentTrie .InsertAll (benchmarkPrefixes )
315229
316230 for _ , testStr := range benchmarkTestStrings {
317231 linearResult := linear .HasPrefix (testStr )
318- charTrieResult := charTrie .HasPrefix (testStr )
319232 segmentTrieResult := segmentTrie .HasPrefix (testStr )
320233
321- if linearResult != charTrieResult {
322- t .Errorf ("Linear vs Character Trie mismatch for %q: linear=%v, charTrie=%v" ,
323- testStr , linearResult , charTrieResult )
324- }
325-
326234 if linearResult != segmentTrieResult {
327235 t .Errorf ("Linear vs Segment Trie mismatch for %q: linear=%v, segmentTrie=%v" ,
328236 testStr , linearResult , segmentTrieResult )
0 commit comments