Skip to content

Commit

Permalink
test: multiple operations
Browse files Browse the repository at this point in the history
as expected, shows a distinct tradeoff between compilation and runtime performance
  • Loading branch information
weiliddat committed Jun 17, 2024
1 parent cd652bc commit eb3a369
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 14 deletions.
29 changes: 15 additions & 14 deletions benchmark/output.csv
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
,sift,sift(compile),sift(run),compiled,compiled(compile),compiled(run)
"explicit $eq",4061,4060,313,1739,1657,123
"implicit $eq",4984,4952,309,1713,1613,122
"explicit $eq, full object match",4351,4076,569,2418,1985,526
"nested object path, explicit $eq",4190,4053,419,3147,3071,127
"nested object path, implicit $eq",5106,4930,418,3102,2992,127
"nested object path, full object match",4306,4024,587,4022,3665,436
"implicit $eq, object against null",4119,4002,447,3056,2955,134
"explicit $eq, object against null",4188,4046,443,3068,2965,136
"match against arrays on ov",4920,4127,1108,4359,3582,799
"match against arrays on doc",5374,4957,716,3160,3016,195
"unindexed nested object path with intermediate arrays on doc",5189,4952,532,3115,2994,163
"unindexed nested object path against null",4328,3963,625,3061,2971,186
"indexed nested object path with intermediate arrays on doc",5209,4932,540,6202,6061,284
"nested arrays on doc",5339,4946,684,6189,6072,133
"explicit $eq",4104,4055,383,1652,1576,116
"implicit $eq",5072,5016,370,1650,1574,117
"explicit $eq, full object match",4413,4089,664,2346,1921,519
"nested object path, explicit $eq",4224,4065,476,2935,2845,123
"nested object path, implicit $eq",5220,5021,471,2891,2814,120
"nested object path, full object match",4394,4017,647,3858,3498,448
"implicit $eq, object against null",4174,3974,501,2789,2733,127
"explicit $eq, object against null",4263,4053,499,2842,2791,124
"match against arrays on ov",5061,4105,1244,4122,3394,795
"match against arrays on doc",5534,5025,800,2979,2804,184
"unindexed nested object path with intermediate arrays on doc",5314,5013,585,2921,2815,157
"unindexed nested object path against null",4369,3979,686,2872,2705,179
"indexed nested object path with intermediate arrays on doc",5309,5005,600,5798,5477,308
"nested arrays on doc",5443,5042,744,5671,5548,165
"multiple conditions",9200,7281,2149,15114,14735,334
Binary file modified benchmark/output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified benchmark/output.xlsx
Binary file not shown.
10 changes: 10 additions & 0 deletions benchmark/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ const cases: BenchCase[] = [
{ foo: [{ bar: "baz" }] },
],
},
{
name: "multiple conditions",
query: { "foo.bar.baz": "qux", "foo.bar.qux": "baz", "foo.bar.bla": "jaz" },
input: [
{ foo: [{ bar: [{ baz: "qux" }, { qux: "baz" }, { bla: "jaz" }] }] },
{},
{ foo: "bar" },
{ foo: [{ bar: "baz" }] },
],
},
];

warmupBench(cases);
Expand Down
17 changes: 17 additions & 0 deletions test/ops.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,23 @@ describe("$and", async () => {
input: [{ foo: "bar", qux: "baz" }, { foo: "bar" }, {}, { foo: "baz" }],
expected: [{ foo: "bar", qux: "baz" }],
},
{
name: "multiple conditions",
query: {
"foo.bar.baz": "qux",
"foo.bar.qux": "baz",
"foo.bar.bla": "jaz",
},
input: [
{ foo: [{ bar: [{ baz: "qux" }, { qux: "baz" }, { bla: "jaz" }] }] },
{},
{ foo: "bar" },
{ foo: [{ bar: "baz" }] },
],
expected: [
{ foo: [{ bar: [{ baz: "qux" }, { qux: "baz" }, { bla: "jaz" }] }] },
],
},
];

runTestCases(testCases);
Expand Down

0 comments on commit eb3a369

Please sign in to comment.