github.com/ipld/go-ipld-prime@v0.21.0/storage/sharding/sharding_bench_test.go (about) 1 package sharding 2 3 import ( 4 "testing" 5 ) 6 7 var globalSink interface{} 8 9 // This doesn't benchmark each of the sharding functions because... they're all roughly the same, really. 10 // It's mainly to make sure that our documentation's claim about zero-alloc operation is true. 11 func Benchmark(b *testing.B) { 12 b.ReportAllocs() 13 k := "abcdefgh" 14 v := make([]string, 0, 3) 15 var sink string 16 for n := 0; n < b.N; n++ { 17 v = v[0:0] 18 Shard_r133(k, &v) 19 sink = v[1] 20 } 21 globalSink = sink // make very very sure the compiler can't optimize our 'v' into oblivion. 22 }