Skip to content

Commit 3c6a442

Browse files
committed
Track Get event counts during the find benchmark.
This new graph tracks BenchmarkSetIndividual-addntlBlocks-per-addntlEntry-vs-scale.svg pretty darn closely, just with a scaling of the Y axis (it more or less shifts up by one! Which I suppose would make sense).
1 parent a4177d2 commit 3c6a442

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

hamt_bench_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func init() {
9191
benchdraw --filter=BenchmarkSetBulk --plot=line --x=n "--y=addntlBlocks/addntlEntry" < sample > BenchmarkSetBulk-addntlBlocks-per-addntlEntry-vs-scale.svg
9292
benchdraw --filter=BenchmarkSetIndividual --plot=line --x=n "--y=addntlBlocks/addntlEntry" < sample > BenchmarkSetIndividual-addntlBlocks-per-addntlEntry-vs-scale.svg
9393
benchdraw --filter=BenchmarkFind --plot=line --x=n "--y=ns/op" < sample > BenchmarkFind-speed-vs-scale.svg
94+
benchdraw --filter=BenchmarkFind --plot=line --x=n "--y=getEvts/find" < sample > BenchmarkFind-getEvts-vs-scale.svg
9495
*/
9596
// (The 'benchdraw' command alluded to here is https://github.com/cep21/benchdraw .)
9697

@@ -226,7 +227,8 @@ func BenchmarkFind(b *testing.B) {
226227
func doBenchmarkEntriesCount(num int, bitWidth int) func(b *testing.B) {
227228
r := rander{rand.New(rand.NewSource(int64(num)))}
228229
return func(b *testing.B) {
229-
cs := cbor.NewCborStore(newMockBlocks())
230+
blockstore := newMockBlocks()
231+
cs := cbor.NewCborStore(blockstore)
230232
n := NewNode(cs, UseTreeBitWidth(bitWidth))
231233

232234
var keys []string
@@ -248,6 +250,7 @@ func doBenchmarkEntriesCount(num int, bitWidth int) func(b *testing.B) {
248250
}
249251

250252
runtime.GC()
253+
blockstore.stats = blockstoreStats{}
251254
b.ResetTimer()
252255
b.ReportAllocs()
253256

@@ -261,5 +264,7 @@ func doBenchmarkEntriesCount(num int, bitWidth int) func(b *testing.B) {
261264
b.Fatal(err)
262265
}
263266
}
267+
b.ReportMetric(float64(blockstore.stats.evtcntGet)/float64(b.N), "getEvts/find")
268+
b.ReportMetric(float64(blockstore.stats.evtcntPut)/float64(b.N), "putEvts/find") // surely this is zero, but for completeness.
264269
}
265270
}

0 commit comments

Comments
 (0)