|
|
@ -3,42 +3,26 @@ var Datastore = require('../lib/datastore') |
|
|
|
, fs = require('fs') |
|
|
|
, fs = require('fs') |
|
|
|
, path = require('path') |
|
|
|
, path = require('path') |
|
|
|
, async = require('async') |
|
|
|
, async = require('async') |
|
|
|
, commonUtilities = require('./commonUtilities') |
|
|
|
|
|
|
|
, execTime = require('exec-time') |
|
|
|
, execTime = require('exec-time') |
|
|
|
, profiler = new execTime('UPDATE BENCH') |
|
|
|
, profiler = new execTime('UPDATE BENCH') |
|
|
|
, d = new Datastore(benchDb) |
|
|
|
, commonUtilities = require('./commonUtilities') |
|
|
|
, program = require('commander') |
|
|
|
, config = commonUtilities.getConfiguration(benchDb) |
|
|
|
, n |
|
|
|
, d = config.d |
|
|
|
|
|
|
|
, n = config.n |
|
|
|
; |
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
program |
|
|
|
|
|
|
|
.option('-n --number [number]', 'Size of the collection to test on', parseInt) |
|
|
|
|
|
|
|
.option('-i --with-index', 'Test with an index') |
|
|
|
|
|
|
|
.parse(process.argv); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
n = program.number || 10000; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log("----------------------------"); |
|
|
|
|
|
|
|
console.log("Test with " + n + " documents"); |
|
|
|
|
|
|
|
console.log(program.withIndex ? "Use an index" : "Don't use an index"); |
|
|
|
|
|
|
|
console.log("----------------------------"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async.waterfall([ |
|
|
|
async.waterfall([ |
|
|
|
async.apply(commonUtilities.prepareDb, benchDb) |
|
|
|
async.apply(commonUtilities.prepareDb, benchDb) |
|
|
|
, function (cb) { |
|
|
|
, function (cb) { |
|
|
|
d.loadDatabase(function (err) { |
|
|
|
d.loadDatabase(function (err) { |
|
|
|
if (err) { return cb(err); } |
|
|
|
if (err) { return cb(err); } |
|
|
|
if (program.withIndex) { |
|
|
|
if (config.program.withIndex) { d.ensureIndex({ fieldName: 'docNumber' }); } |
|
|
|
d.ensureIndex({ fieldName: 'docNumber' }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
cb(); |
|
|
|
cb(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
, function (cb) { profiler.beginProfiling(); return cb(); } |
|
|
|
, function (cb) { profiler.beginProfiling(); return cb(); } |
|
|
|
, async.apply(commonUtilities.insertDocs, d, n, profiler) |
|
|
|
, async.apply(commonUtilities.insertDocs, d, n, profiler) |
|
|
|
|
|
|
|
|
|
|
|
// CHECK THAT MULTIPLE LOAD DATABASE DONT SCREW INDEXES
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Test with update only one document
|
|
|
|
// Test with update only one document
|
|
|
|
, function (cb) { profiler.step('MULTI: FALSE'); return cb(); } |
|
|
|
, function (cb) { profiler.step('MULTI: FALSE'); return cb(); } |
|
|
|
, async.apply(commonUtilities.updateDocs, { multi: false }, d, n, profiler) |
|
|
|
, async.apply(commonUtilities.updateDocs, { multi: false }, d, n, profiler) |
|
|
|