benchmark/benchmark_binary.js
function perfFindInterlacedInserts(multiplier) {
  var start, end;
  var totalTimes = [];
  var totalMS = 0;

  var loopIterations = arraySize;
  if (typeof (multiplier) != "undefined") {
    loopIterations = loopIterations * multiplier;
  }

  for (var idx = 0; idx < loopIterations; idx++) {
    var customidx = Math.floor(Math.random() * arraySize) + 1;

    start = process.hrtime();
    var results = samplecoll.find({
      'customId': customidx
    });
    // insert junk record, now (outside timing routine) to force index rebuild
    var obj = samplecoll.insert({
        customId: 999,
        val: 999,
        val2: 999,
        val3: "more data 1234567890"
    });  
    
    end = process.hrtime(start);
    totalTimes.push(end);
    
  }

  for (var idx = 0; idx < totalTimes.length; idx++) {
    totalMS += totalTimes[idx][0] * 1e3 + totalTimes[idx][1] / 1e6;
  }

  totalMS = totalMS.toFixed(2);
  var rate = loopIterations * 1000 / totalMS;
  rate = rate.toFixed(2);
  console.log("interlaced inserts + coll.find() : " + totalMS + "ms (" + rate + " ops/s) " + loopIterations + " iterations");
  
}
function perfFindInterlacedInserts(multiplier) {
  var start, end;
  var totalTimes = [];
  var totalMS = 0;

  var loopIterations = arraySize;
  if (typeof (multiplier) != "undefined") {
    loopIterations = loopIterations * multiplier;
  }

  for (var idx = 0; idx < loopIterations; idx++) {
    var customidx = Math.floor(Math.random() * arraySize) + 1;

    start = process.hrtime();
    var results = samplecoll.find({
      'customId': customidx
    });
    // insert junk record, now (outside timing routine) to force index rebuild
    var obj = samplecoll.insert({
        customId: 999,
        val: 999,
        val2: 999,
        val3: "more data 1234567890"
    });  
    
    end = process.hrtime(start);
    totalTimes.push(end);
    
  }

  for (var idx = 0; idx < totalTimes.length; idx++) {
    totalMS += totalTimes[idx][0] * 1e3 + totalTimes[idx][1] / 1e6;
  }

  totalMS = totalMS.toFixed(2);
  var rate = loopIterations * 1000 / totalMS;
  rate = rate.toFixed(2);
  console.log("interlaced inserts + coll.find() : " + totalMS + "ms (" + rate + " ops/s) " + loopIterations + " iterations");
  
}
function perfFindInterlacedInserts ( multiplier ) { var start , end ; var totalTimes = [ ] ; var totalMS = 0 ; var loopIterations = arraySize ; if ( typeof ( multiplier ) != "undefined" ) { loopIterations = loopIterations * multiplier ; } for ( var idx = 0 ; idx < loopIterations ; idx ++ ) { var customidx = Math . floor ( Math . random ( ) * arraySize ) + 1 ; start = process . hrtime ( ) ; var results = samplecoll . find ( { 'customId' : customidx } ) ; // insert junk record, now (outside timing routine) to force index rebuild var obj = samplecoll . insert ( { customId : 999 , val : 999 , val2 : 999 , val3 : "more data 1234567890" } ) ; end = process . hrtime ( start ) ; totalTimes . push ( end ) ; } for ( var idx = 0 ; idx < totalTimes . length ; idx ++ ) { totalMS += totalTimes [ idx ] [ 0 ] * 1e3 + totalTimes [ idx ] [ 1 ] / 1e6 ; } totalMS = totalMS . toFixed ( 2 ) ; var rate = loopIterations * 1000 / totalMS ; rate = rate . toFixed ( 2 ) ; console . log ( "interlaced inserts + coll.find() : " + totalMS + "ms (" + rate + " ops/s) " + loopIterations + " iterations" ) ; }
Find Interlaced Inserts ->  insert 5000, for 5000 more iterations insert same test obj after
Find Interlaced Inserts - > insert 5000 for 5000 more iterations insert same test obj after