1var benchmark = require("benchmark"); 2 3function newBenchmark(messageName, filename, language) { 4 var benches = []; 5 return { 6 suite: new benchmark.Suite(messageName + filename + language ) 7 .on("add", function(event) { 8 benches.push(event.target); 9 }) 10 .on("start", function() { 11 process.stdout.write( 12 "benchmarking message " + messageName 13 + " of dataset file " + filename 14 + "'s performance ..." + "\n\n"); 15 }) 16 .on("cycle", function(event) { 17 process.stdout.write(String(event.target) + "\n"); 18 }) 19 .on("complete", function() { 20 var getHz = function(bench) { 21 return 1 / (bench.stats.mean + bench.stats.moe); 22 } 23 benches.forEach(function(val, index) { 24 benches[index] = getHz(val); 25 }); 26 }), 27 benches: benches 28 } 29} 30 31module.exports = { 32 newBenchmark: newBenchmark 33} 34