1 | var Datastore = require('../lib/datastore')
|
2 | , benchDb = 'workspace/insert.bench.db'
|
3 | , async = require('async')
|
4 | , execTime = require('exec-time')
|
5 | , profiler = new execTime('INSERT BENCH')
|
6 | , commonUtilities = require('./commonUtilities')
|
7 | , config = commonUtilities.getConfiguration(benchDb)
|
8 | , d = config.d
|
9 | , n = config.n
|
10 | ;
|
11 |
|
12 | async.waterfall([
|
13 | async.apply(commonUtilities.prepareDb, benchDb)
|
14 | , function (cb) {
|
15 | d.loadDatabase(function (err) {
|
16 | if (err) { return cb(err); }
|
17 | if (config.program.withIndex) {
|
18 | d.ensureIndex({ fieldName: 'docNumber' });
|
19 | n = 2 * n;
|
20 |
|
21 |
|
22 |
|
23 | }
|
24 | cb();
|
25 | });
|
26 | }
|
27 | , function (cb) { profiler.beginProfiling(); return cb(); }
|
28 | , async.apply(commonUtilities.insertDocs, d, n, profiler)
|
29 | ], function (err) {
|
30 | profiler.step("Benchmark finished");
|
31 |
|
32 | if (err) { return console.log("An error was encountered: ", err); }
|
33 | });
|