Skip to content

Commit

Permalink
fix benchmark
Browse files Browse the repository at this point in the history
Signed-off-by: Kosuke Morimoto <[email protected]>
  • Loading branch information
kmrmt authored and actions-user committed Sep 24, 2020
1 parent 1d9d0ba commit 7a57e13
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions hack/benchmark/assets/x1b/loader_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,18 @@ func BenchmarkBVecs(b *testing.B) {
}
}()

i := 0
b.Run(bvecsFile, func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()

i := 0
size := bv.Size()
for n := 0; n < bb.N; n++ {
_, err := bv.Load(i)
switch err {
case nil:
i++
case ErrOutOfBounds:
i = 0
default:
_, err := bv.Load(i % size)
if err != nil {
bb.Fatal(err)
}
i++
}
})
}
Expand All @@ -65,20 +63,18 @@ func BenchmarkFVecs(b *testing.B) {
}
}()

i := 0
b.Run(fvecsFile, func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()

i := 0
size := fv.Size()
for n := 0; n < bb.N; n++ {
_, err := fv.Load(i)
switch err {
case nil:
i++
case ErrOutOfBounds:
i = 0
default:
_, err := fv.Load(i % size)
if err != nil {
bb.Fatal(err)
}
i++
}
})
}
Expand All @@ -94,20 +90,18 @@ func BenchmarkIVecs(b *testing.B) {
}
}()

i := 0
b.Run(ivecsFile, func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()

i := 0
size := iv.Size()
for n := 0; n < bb.N; n++ {
_, err := iv.Load(i)
switch err {
case nil:
i++
case ErrOutOfBounds:
i = 0
default:
_, err := iv.Load(i % size)
if err != nil {
bb.Fatal(err)
}
i++
}
})
}

0 comments on commit 7a57e13

Please sign in to comment.