0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 15:06:33 +01:00
nodejs/benchmark/run.js
Ryan ad9d683f9f API: rename node.Process to node.ChildProcess
This is to avoid confusion with the global "process" object, especially for
the instances of node.Process.
2009-08-26 22:36:45 +02:00

30 lines
736 B
JavaScript

var benchmarks = [ "static_http_server.js"
, "timers.js"
, "process_loop.js"
];
var benchmark_dir = node.path.dirname(__filename);
function exec (script, callback) {
var command = ARGV[0] + " " + node.path.join(benchmark_dir, script);
var start = new Date();
var child = node.createChildProcess(command);
child.addListener("exit", function (code) {
var elapsed = new Date() - start;
callback(elapsed, code);
});
}
function runNext (i) {
if (i >= benchmarks.length) return;
print(benchmarks[i] + ": ");
exec(benchmarks[i], function (elapsed, code) {
if (code != 0) {
puts("ERROR ");
}
puts(elapsed);
runNext(i+1);
});
};
runNext(0);