Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic benchmark for query pushdowns #1689

Merged
merged 12 commits into from
Dec 28, 2022
Prev Previous commit
Next Next commit
wip
  • Loading branch information
noisersup committed Dec 27, 2022
commit 63240048979dcb6ce381c2e322d6a3861d91c55d
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)
AlekSi marked this conversation as resolved.
Show resolved Hide resolved

b.Run("ObjectID", func(b *testing.B) {
noisersup marked this conversation as resolved.
Show resolved Hide resolved
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"}})
rumyantseva marked this conversation as resolved.
Show resolved Hide resolved
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)
}
})
}