Skip to content

Commit

Permalink
Quick and dirty "benchmark": Runs selector_compiler test 100 times, a…
Browse files Browse the repository at this point in the history
…nd for each

selector, compiles it once and evaluates it 100 times.
  • Loading branch information
glasser committed Dec 18, 2012
1 parent ce204e0 commit 47b31c8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/minimongo/minimongo_tests.js
Expand Up @@ -251,8 +251,11 @@ Tinytest.add("minimongo - misc", function (test) {
});

Tinytest.add("minimongo - selector_compiler", function (test) {
_.times(100, function () {
var matches = function (should_match, selector, doc) {
var does_match = LocalCollection._matches(selector, doc);
var compiled = LocalCollection._compileSelector(selector);
_.times(100, function () {
var does_match = compiled(doc);
if (does_match != should_match) {
// XXX super janky
test.fail({type: "minimongo-ordering",
Expand All @@ -263,6 +266,7 @@ Tinytest.add("minimongo - selector_compiler", function (test) {
document: JSON.stringify(doc)
});
}
});
};

var match = _.bind(matches, null, true);
Expand Down Expand Up @@ -867,6 +871,7 @@ Tinytest.add("minimongo - selector_compiler", function (test) {
// - $elemMatch
// - non-scalar arguments to $gt, $lt, etc
});
});

Tinytest.add("minimongo - ordering", function (test) {
// value ordering
Expand Down

0 comments on commit 47b31c8

Please sign in to comment.