bench when document doesn't exist, it's the same story

pull/1513/head
Thibault Duplessis 2016-01-24 15:55:07 +07:00
parent 2c6ca28fac
commit 318a980502
1 changed files with 8 additions and 10 deletions

View File

@ -1,10 +1,14 @@
var limit = 50 * 1000;
var coll = db.relation;
var query = {
_id: 'thibault/legendary22bcloud'
};
var expected = false;
function timer(name, f) {
print('Start ' + name);
var start = new Date().getTime();
if (f() !== true) print('FAILS');
if (f() !== expected) print('FAILS');
else {
for (var i = 0; i < limit; i++) f();
print(name + ': ' + (new Date().getTime() - start));
@ -12,17 +16,11 @@ function timer(name, f) {
}
timer('count', function() {
return coll.count({
_id: 'thibault/legendarybcloud'
}) === 1;
return coll.count(query) === 1;
});
timer('find', function() {
return coll.find({
_id: 'thibault/legendarybcloud'
}).limit(1).length() === 1;
return coll.find(query).limit(1).length() === 1;
});
timer('findOne', function() {
return coll.findOne({
_id: 'thibault/legendarybcloud'
}) !== null;
return coll.findOne(query) !== null;
});