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