aboutsummaryrefslogtreecommitdiff
path: root/benchmarks/js/benchmark_suite.js
blob: c95024b2e244d63dc58fcdb70bc1e0ce3f038b16 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var benchmark = require("benchmark");

function newBenchmark(messageName, filename, language) {
  var benches = [];
  return {
    suite: new benchmark.Suite(messageName + filename + language )
      .on("add", function(event) {
          benches.push(event.target);
      })
      .on("start", function() {
          process.stdout.write(
            "benchmarking message " + messageName 
            + " of dataset file " + filename 
            + "'s performance ..." + "\n\n");
      })
      .on("cycle", function(event) {
          process.stdout.write(String(event.target) + "\n");
      })
      .on("complete", function() {
          var getHz = function(bench) {
            return 1 / (bench.stats.mean + bench.stats.moe);
          }
          benches.forEach(function(val, index) {
            benches[index] = getHz(val); 
          });
      }),
     benches: benches
  }
}

module.exports = {
        newBenchmark: newBenchmark
}