snapshot benchmarking

This commit is contained in:
Todd Gruben 2018-01-17 14:27:27 -06:00 committed by Travis Turner
parent e0fc49b512
commit 3ae10fbd95
No known key found for this signature in database
GPG key ID: 7F08008DFD9314C9

View file

@ -1075,3 +1075,25 @@ func TestFragment_Snapshot_Run(t *testing.T) {
t.Fatalf("unexpected count (reopen): %d", n)
}
}
func BenchmarkFragment_Snapshot(b *testing.B) {
if *FragmentPath == "" {
b.Skip("no fragment specified")
}
// Open the fragment specified by the path.
f := pilosa.NewFragment(*FragmentPath, "i", "f", pilosa.ViewStandard, 0)
if err := f.Open(); err != nil {
b.Fatal(err)
}
defer f.Close()
// Reset timer and execute benchmark.
b.ResetTimer()
for i := 0; i < b.N; i++ {
err := f.Snapshot()
if err != nil {
b.Fatalf("unexpected count (reopen): %s", err)
}
}
}