2009-10-31 20:06:46 +01:00
|
|
|
var path = require("path");
|
2010-03-23 02:47:04 +01:00
|
|
|
var sys = require("sys");
|
|
|
|
var childProcess = require("child_process");
|
|
|
|
var benchmarks = [ "timers.js"
|
2009-07-13 12:48:59 +02:00
|
|
|
, "process_loop.js"
|
2010-03-23 02:47:04 +01:00
|
|
|
, "static_http_server.js"
|
2009-07-13 12:48:59 +02:00
|
|
|
];
|
|
|
|
|
2010-03-09 04:06:25 +01:00
|
|
|
var benchmarkDir = path.dirname(__filename);
|
2009-07-13 12:48:59 +02:00
|
|
|
|
|
|
|
function exec (script, callback) {
|
|
|
|
var start = new Date();
|
2010-03-23 02:47:04 +01:00
|
|
|
var child = childProcess.spawn(process.argv[0], [path.join(benchmarkDir, script)]);
|
2009-08-26 22:11:51 +02:00
|
|
|
child.addListener("exit", function (code) {
|
2009-07-13 12:48:59 +02:00
|
|
|
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] + ": ");
|
2009-07-13 12:48:59 +02:00
|
|
|
exec(benchmarks[i], function (elapsed, code) {
|
|
|
|
if (code != 0) {
|
2010-03-09 04:06:25 +01:00
|
|
|
sys.puts("ERROR ");
|
2009-07-13 12:48:59 +02:00
|
|
|
}
|
2010-03-09 04:06:25 +01:00
|
|
|
sys.puts(elapsed);
|
2009-07-13 12:48:59 +02:00
|
|
|
runNext(i+1);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
runNext(0);
|