0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 07:00:59 +01:00
nodejs/benchmark/run.js

31 lines
778 B
JavaScript
Raw Normal View History

var path = require("path");
2010-03-09 04:06:25 +01:00
var sys = require("../lib/sys");
var benchmarks = [ "static_http_server.js"
, "timers.js"
, "process_loop.js"
];
2010-03-09 04:06:25 +01:00
var benchmarkDir = path.dirname(__filename);
function exec (script, callback) {
var start = new Date();
2010-03-09 04:06:25 +01:00
var child = process.createChildProcess(process.ARGV[0], [path.join(benchmarkDir, script)]);
child.addListener("exit", function (code) {
var elapsed = new Date() - start;
callback(elapsed, code);
});
}
function runNext (i) {
if (i >= benchmarks.length) return;
2010-03-09 04:06:25 +01:00
sys.print(benchmarks[i] + ": ");
exec(benchmarks[i], function (elapsed, code) {
if (code != 0) {
2010-03-09 04:06:25 +01:00
sys.puts("ERROR ");
}
2010-03-09 04:06:25 +01:00
sys.puts(elapsed);
runNext(i+1);
});
};
runNext(0);