Commit 80febfe2 authored by Eric Myhre's avatar Eric Myhre

Add sanity check on visit count to traversal bench

parent 61ebf6e2
......@@ -27,9 +27,15 @@ func SpecBenchmarkWalkMapStrInt_3n(b *testing.B, nb ipld.NodeBuilder) {
panic(err)
}
b.ResetTimer()
var visitCountSanityCheck int
for i := 0; i < b.N; i++ {
visitCountSanityCheck = 0
traversal.WalkMatching(n, sel, func(tp traversal.Progress, n ipld.Node) error {
return nil // no need to do anything here; just care about exercising the walk internals.
visitCountSanityCheck++ // this sanity check is sufficiently cheap to be worth it
return nil // no need to do anything here; just care about exercising the walk internals.
})
}
if visitCountSanityCheck != 3 {
b.Fatalf("visitCountSanityCheck should be 3, got %d", visitCountSanityCheck)
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment