|
|
|
@ -36,18 +36,20 @@ async.waterfall([ |
|
|
|
|
|
|
|
|
|
console.log("Inserting " + n + " documents"); |
|
|
|
|
|
|
|
|
|
async.whilst( function () { return i < n; } |
|
|
|
|
, function (_cb) { |
|
|
|
|
function insertOne(i) { |
|
|
|
|
if (i === n) { // Finished
|
|
|
|
|
var timeTaken = (new Date()).getTime() - beg.getTime(); // In ms
|
|
|
|
|
console.log("Time taken: " + (timeTaken / 1000) + "s"); |
|
|
|
|
return cb(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
d.insert({ docNumber: i }, function (err) { |
|
|
|
|
i += 1; |
|
|
|
|
return _cb(err); |
|
|
|
|
process.nextTick(function () { |
|
|
|
|
insertOne(i + 1); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}, function (err) { |
|
|
|
|
var timeTaken = (new Date()).getTime() - beg.getTime(); // In ms
|
|
|
|
|
if (err) { return cb(err); } |
|
|
|
|
console.log("Time taken: " + (timeTaken / 1000) + "s"); |
|
|
|
|
return cb(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
insertOne(0); |
|
|
|
|
} |
|
|
|
|
, function (cb) { |
|
|
|
|
var beg = new Date() |
|
|
|
@ -55,20 +57,42 @@ async.waterfall([ |
|
|
|
|
|
|
|
|
|
console.log("Finding " + n + " documents"); |
|
|
|
|
|
|
|
|
|
async.whilst( function () { return i < n; } |
|
|
|
|
, function (_cb) { |
|
|
|
|
function find(i) { |
|
|
|
|
if (i === n) { // Finished
|
|
|
|
|
var timeTaken = (new Date()).getTime() - beg.getTime(); // In ms
|
|
|
|
|
console.log("Time taken: " + (timeTaken / 1000) + "s"); |
|
|
|
|
return cb(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
d.find({ docNumber: order[i] }, function (err, docs) { |
|
|
|
|
i += 1; |
|
|
|
|
if (docs.length !== 1) { return _cb(docs); } |
|
|
|
|
return _cb(err); |
|
|
|
|
if (docs.length !== 1) { return cb('One find didnt work'); } |
|
|
|
|
process.nextTick(function () { |
|
|
|
|
find(i + 1); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}, function (err) { |
|
|
|
|
var timeTaken = (new Date()).getTime() - beg.getTime(); // In ms
|
|
|
|
|
if (err) { return cb(err); } |
|
|
|
|
console.log("Time taken: " + (timeTaken / 1000) + "s"); |
|
|
|
|
return cb(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
find(0); |
|
|
|
|
} |
|
|
|
|
//, function (cb) {
|
|
|
|
|
//var beg = new Date()
|
|
|
|
|
//, i = 0;
|
|
|
|
|
|
|
|
|
|
//console.log("Finding " + n + " documents");
|
|
|
|
|
|
|
|
|
|
//async.whilst( function () { return i < n; }
|
|
|
|
|
//, function (_cb) {
|
|
|
|
|
//d.find({ docNumber: order[i] }, function (err, docs) {
|
|
|
|
|
//i += 1;
|
|
|
|
|
//if (docs.length !== 1) { return _cb(docs); }
|
|
|
|
|
//return _cb(err);
|
|
|
|
|
//});
|
|
|
|
|
//}, function (err) {
|
|
|
|
|
//var timeTaken = (new Date()).getTime() - beg.getTime(); // In ms
|
|
|
|
|
//if (err) { return cb(err); }
|
|
|
|
|
//console.log("Time taken: " + (timeTaken / 1000) + "s");
|
|
|
|
|
//return cb();
|
|
|
|
|
//});
|
|
|
|
|
//}
|
|
|
|
|
], function (err) { |
|
|
|
|
console.log("Benchmark finished"); |
|
|
|
|
|
|
|
|
|