[#1445] metabase: Fix BenchmarkListWithCursor
The benchmark didn't work because
- database was closed right after its creation (added in #895)
- couldn't properly compare returned error (added in fcdbf5e509
)
Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
parent
ad01fb958a
commit
ef4b71550e
1 changed files with 3 additions and 2 deletions
|
@ -18,6 +18,8 @@ import (
|
||||||
|
|
||||||
func BenchmarkListWithCursor(b *testing.B) {
|
func BenchmarkListWithCursor(b *testing.B) {
|
||||||
db := listWithCursorPrepareDB(b)
|
db := listWithCursorPrepareDB(b)
|
||||||
|
defer func() { require.NoError(b, db.Close()) }()
|
||||||
|
|
||||||
b.Run("1 item", func(b *testing.B) {
|
b.Run("1 item", func(b *testing.B) {
|
||||||
benchmarkListWithCursor(b, db, 1)
|
benchmarkListWithCursor(b, db, 1)
|
||||||
})
|
})
|
||||||
|
@ -33,7 +35,6 @@ func listWithCursorPrepareDB(b *testing.B) *meta.DB {
|
||||||
db := newDB(b, meta.WithMaxBatchSize(1), meta.WithBoltDBOptions(&bbolt.Options{
|
db := newDB(b, meta.WithMaxBatchSize(1), meta.WithBoltDBOptions(&bbolt.Options{
|
||||||
NoSync: true,
|
NoSync: true,
|
||||||
})) // faster single-thread generation
|
})) // faster single-thread generation
|
||||||
defer func() { require.NoError(b, db.Close()) }()
|
|
||||||
|
|
||||||
obj := testutil.GenerateObject()
|
obj := testutil.GenerateObject()
|
||||||
for i := range 100_000 { // should be a multiple of all batch sizes
|
for i := range 100_000 { // should be a multiple of all batch sizes
|
||||||
|
@ -55,7 +56,7 @@ func benchmarkListWithCursor(b *testing.B, db *meta.DB, batchSize int) {
|
||||||
for range b.N {
|
for range b.N {
|
||||||
res, err := db.ListWithCursor(context.Background(), prm)
|
res, err := db.ListWithCursor(context.Background(), prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != meta.ErrEndOfListing {
|
if !errors.Is(err, meta.ErrEndOfListing) {
|
||||||
b.Fatalf("error: %v", err)
|
b.Fatalf("error: %v", err)
|
||||||
}
|
}
|
||||||
prm.SetCursor(nil)
|
prm.SetCursor(nil)
|
||||||
|
|
Loading…
Add table
Reference in a new issue