Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
noisersup committed Dec 27, 2022
1 parent 611fdac commit 6324004
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions integration/benchmarks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ func BenchmarkPushdowns(b *testing.B) {

id := res.InsertedID

// run benchmark with query pushdown
_, err = coll.InsertOne(ctx, bson.D{{"v", "foo"}})
require.NoError(b, err)

b.Run("ObjectID", func(b *testing.B) {
for i := 0; i < b.N; i++ {
cur, err := coll.Find(ctx, bson.D{{"_id", id}})
Expand All @@ -41,18 +43,34 @@ func BenchmarkPushdowns(b *testing.B) {
var res []bson.D
err = cur.All(ctx, &res)
require.NoError(b, err)

require.NotEmpty(b, res)
}
})

// run benchmark without query pushdown
b.Run("NoPushdown", func(b *testing.B) {
b.Run("StringID", func(b *testing.B) {
for i := 0; i < b.N; i++ {
cur, err := coll.Find(ctx, bson.D{{"_id", "string"}})
require.NoError(b, err)

var res []bson.D
err = cur.All(ctx, &res)
require.NoError(b, err)

require.NotEmpty(b, res)
}
})

b.Run("NoPushdown", func(b *testing.B) {
for i := 0; i < b.N; i++ {
cur, err := coll.Find(ctx, bson.D{{"v", 42.0}})
require.NoError(b, err)

var res []bson.D
err = cur.All(ctx, &res)
require.NoError(b, err)

require.NotEmpty(b, res)
}
})
}

0 comments on commit 6324004

Please sign in to comment.