From 114556b993a0d351db130b33e3da055c3709ec01 Mon Sep 17 00:00:00 2001 From: Louis Chatriot Date: Thu, 5 Nov 2015 10:30:53 +0100 Subject: [PATCH] Updated benchmarks for better readability --- benchmarks/commonUtilities.js | 17 ++++++++++------- benchmarks/remove.js | 1 - 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/benchmarks/commonUtilities.js b/benchmarks/commonUtilities.js index 3b3d08e..48b12d2 100644 --- a/benchmarks/commonUtilities.js +++ b/benchmarks/commonUtilities.js @@ -97,8 +97,10 @@ module.exports.insertDocs = function (d, n, profiler, cb) { function runFrom(i) { if (i === n) { // Finished - console.log("===== RESULT (insert) ===== " + Math.floor(1000* n / profiler.elapsedSinceLastStep()) + " ops/s"); + var opsPerSecond = Math.floor(1000* n / profiler.elapsedSinceLastStep()); + console.log("===== RESULT (insert) ===== " + opsPerSecond + " ops/s"); profiler.step('Finished inserting ' + n + ' docs'); + profiler.insertOpsPerSecond = opsPerSecond; return cb(); } @@ -153,12 +155,12 @@ module.exports.findDocsWithIn = function (d, n, profiler, cb) { // Preparing all the $in arrays, will take some time for (i = 0; i < n; i += 1) { ins[i] = []; - + for (j = 0; j < arraySize; j += 1) { ins[i].push((i + j) % n); } } - + profiler.step("Finding " + n + " documents WITH $IN OPERATOR"); function runFrom(i) { @@ -251,10 +253,11 @@ module.exports.removeDocs = function (options, d, n, profiler, cb) { function runFrom(i) { if (i === n) { // Finished - console.log("===== RESULT (1 remove + 1 insert) ===== " + Math.floor(1000* n / profiler.elapsedSinceLastStep()) + " ops/s"); - console.log("====== IMPORTANT: Please note that this is the time that was needed to perform " + n + " removes and " + n + " inserts"); - console.log("====== The extra inserts are needed to keep collection size at " + n + " items for the benchmark to make sense"); - console.log("====== Use the insert speed logged above to calculate the actual remove speed, which is higher (should be significantly so if you use indexing)"); + // opsPerSecond corresponds to 1 insert + 1 remove, needed to keep collection size at 10,000 + // We need to subtract the time taken by one insert to get the time actually taken by one remove + var opsPerSecond = Math.floor(1000 * n / profiler.elapsedSinceLastStep()); + var removeOpsPerSecond = Math.floor(1 / ((1 / opsPerSecond) - (1 / profiler.insertOpsPerSecond))) + console.log("===== RESULT (remove) ===== " + removeOpsPerSecond + " ops/s"); profiler.step('Finished removing ' + n + ' docs'); return cb(); } diff --git a/benchmarks/remove.js b/benchmarks/remove.js index f408af7..9c7f522 100644 --- a/benchmarks/remove.js +++ b/benchmarks/remove.js @@ -26,7 +26,6 @@ async.waterfall([ // Test with remove only one document , function (cb) { profiler.step('MULTI: FALSE'); return cb(); } , async.apply(commonUtilities.removeDocs, { multi: false }, d, n, profiler) - // Test with multiple documents , function (cb) { d.remove({}, { multi: true }, function () { return cb(); }); } , async.apply(commonUtilities.insertDocs, d, n, profiler)