Can now use the insert benchmark with an index

pull/2/head
Louis Chatriot 12 years ago
parent bd9fec16db
commit 411aa853fb
  1. 21
      benchmarks/insert.js
  2. 3
      package.json

@ -4,16 +4,31 @@ var Datastore = require('../lib/datastore')
, commonUtilities = require('./commonUtilities')
, execTime = require('exec-time')
, profiler = new execTime('INSERT BENCH')
, n = 10000
, n
, d = new Datastore(benchDb)
, program = require('commander')
;
if (process.argv[2]) { n = parseInt(process.argv[2], 10); }
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.apply(commonUtilities.prepareDb, benchDb)
, function (cb) {
d.loadDatabase(cb);
d.loadDatabase(function (err) {
if (err) { return cb(err); }
if (program.withIndex) { d.ensureIndex('docNumber'); }
cb();
});
}
, function (cb) { profiler.beginProfiling(); return cb(); }
, async.apply(commonUtilities.insertDocs, d, n, profiler)

@ -29,7 +29,8 @@
"mocha": "1.4.x",
"request": "2.9.x",
"sinon": "1.3.x",
"exec-time": "0.0.2"
"exec-time": "0.0.2",
"commander": "1.1.1"
},
"scripts": {
"test": "make test"

Loading…
Cancel
Save