2018-08-08 18:24:09 +00:00
|
|
|
var benchmark = require("benchmark");
|
2018-07-20 23:13:19 +00:00
|
|
|
|
|
|
|
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(
|
2019-02-21 03:28:50 +00:00
|
|
|
"benchmarking message " + messageName
|
|
|
|
+ " of dataset file " + filename
|
2018-07-20 23:13:19 +00:00
|
|
|
+ "'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) {
|
2019-02-21 03:28:50 +00:00
|
|
|
benches[index] = getHz(val);
|
2018-07-20 23:13:19 +00:00
|
|
|
});
|
|
|
|
}),
|
|
|
|
benches: benches
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
newBenchmark: newBenchmark
|
|
|
|
}
|