benchmark/benchmark_web.js
function runStep(step) 
{
  switch (step) {
    case 1 : 
      trace("-- Beginning benchmark --");
      initializeDB();
      initializeUnique();
      setTimeout(function() { runStep(2); }, 100);
      break;
    case 2 : 
      benchGet();
      setTimeout(function() { runStep(3); }, 100);
      break;
    case 3 :
      benchUniquePerf();
      setTimeout(function() { runStep(4); }, 100);
      trace("");
      trace("-- Benchmarking query on non-indexed column --");
      break;
    case 4 : 
      benchFind();	// find benchmark on unindexed customid field
      setTimeout(function() { runStep(5); }, 100);
      break;
    case 5 : 
      benchRS(); // resultset find benchmark on unindexed customid field
      setTimeout(function() { runStep(6); }, 100);
      break;
    case 6 : 
      benchDV();
      setTimeout(function() { runStep(7); }, 100);
      trace("");
      trace("-- Adding Binary Index to query column and repeating benchmarks --");
      break;
    case 7 : 
      samplecoll.ensureIndex("customId");
      setTimeout(function() { runStep(8); }, 100);
      break;
    case 8 : 
      benchFind(20);
      setTimeout(function() { runStep(9); }, 100);
      break;
    case 9 : 
      benchRS(15);
      setTimeout(function() { runStep(10); }, 100);
      break;
    case 10 : 
      benchDV(15);
      trace("");
      trace("done.");
      break;
  }
}
function runStep(step) 
{
  switch (step) {
    case 1 : 
      trace("-- Beginning benchmark --");
      initializeDB();
      initializeUnique();
      setTimeout(function() { runStep(2); }, 100);
      break;
    case 2 : 
      benchGet();
      setTimeout(function() { runStep(3); }, 100);
      break;
    case 3 :
      benchUniquePerf();
      setTimeout(function() { runStep(4); }, 100);
      trace("");
      trace("-- Benchmarking query on non-indexed column --");
      break;
    case 4 : 
      benchFind();	// find benchmark on unindexed customid field
      setTimeout(function() { runStep(5); }, 100);
      break;
    case 5 : 
      benchRS(); // resultset find benchmark on unindexed customid field
      setTimeout(function() { runStep(6); }, 100);
      break;
    case 6 : 
      benchDV();
      setTimeout(function() { runStep(7); }, 100);
      trace("");
      trace("-- Adding Binary Index to query column and repeating benchmarks --");
      break;
    case 7 : 
      samplecoll.ensureIndex("customId");
      setTimeout(function() { runStep(8); }, 100);
      break;
    case 8 : 
      benchFind(20);
      setTimeout(function() { runStep(9); }, 100);
      break;
    case 9 : 
      benchRS(15);
      setTimeout(function() { runStep(10); }, 100);
      break;
    case 10 : 
      benchDV(15);
      trace("");
      trace("done.");
      break;
  }
}
function runStep ( step ) { switch ( step ) { case 1 : trace ( "-- Beginning benchmark --" ) ; initializeDB ( ) ; initializeUnique ( ) ; setTimeout ( function ( ) { runStep ( 2 ) ; } , 100 ) ; break ; case 2 : benchGet ( ) ; setTimeout ( function ( ) { runStep ( 3 ) ; } , 100 ) ; break ; case 3 : benchUniquePerf ( ) ; setTimeout ( function ( ) { runStep ( 4 ) ; } , 100 ) ; trace ( "" ) ; trace ( "-- Benchmarking query on non-indexed column --" ) ; break ; case 4 : benchFind ( ) ; // find benchmark on unindexed customid field setTimeout ( function ( ) { runStep ( 5 ) ; } , 100 ) ; break ; case 5 : benchRS ( ) ; // resultset find benchmark on unindexed customid field setTimeout ( function ( ) { runStep ( 6 ) ; } , 100 ) ; break ; case 6 : benchDV ( ) ; setTimeout ( function ( ) { runStep ( 7 ) ; } , 100 ) ; trace ( "" ) ; trace ( "-- Adding Binary Index to query column and repeating benchmarks --" ) ; break ; case 7 : samplecoll . ensureIndex ( "customId" ) ; setTimeout ( function ( ) { runStep ( 8 ) ; } , 100 ) ; break ; case 8 : benchFind ( 20 ) ; setTimeout ( function ( ) { runStep ( 9 ) ; } , 100 ) ; break ; case 9 : benchRS ( 15 ) ; setTimeout ( function ( ) { runStep ( 10 ) ; } , 100 ) ; break ; case 10 : benchDV ( 15 ) ; trace ( "" ) ; trace ( "done." ) ; break ; } }
async yielding after each step to avoid browser warnings of long running scripts
async yielding after each step to avoid browser warnings of long running scripts