github.com/egonelbre/exp@v0.0.0-20240430123955-ed1d3aa93911/sentinels/bench_test.go (about) 1 package sentinels 2 3 import "testing" 4 5 var ( 6 Items = make([]int, 1<<20) 7 Element = 1534 8 ) 9 10 func BenchmarkSearch_Basic(b *testing.B) { 11 for i := 0; i < b.N; i++ { 12 SearchBasic(Items, Element) 13 } 14 } 15 16 func BenchmarkSearch_Break(b *testing.B) { 17 for i := 0; i < b.N; i++ { 18 SearchBreak(Items, Element) 19 } 20 } 21 22 func BenchmarkSearch_Sentinel(b *testing.B) { 23 for i := 0; i < b.N; i++ { 24 SearchSentinel(Items, Element) 25 } 26 } 27 28 func BenchmarkSearch_Unsafe(b *testing.B) { 29 for i := 0; i < b.N; i++ { 30 SearchUnsafe(Items, Element) 31 } 32 } 33 34 func BenchmarkPartition_Break(b *testing.B) { 35 for i := 0; i < b.N; i++ { 36 PartitionBreak(Items, i%len(Items)) 37 } 38 } 39 40 func BenchmarkPartition_Sentinel(b *testing.B) { 41 for i := 0; i < b.N; i++ { 42 PartitionSentinel(Items, i%len(Items)) 43 } 44 }