mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
05d6319fa0
To use the benchmarks: node benchmarks/run.js or: make benchmark The numbers reported are the elapsed milliseconds the script took to complete. Currently only benching HTTP code and timers.
30 lines
735 B
JavaScript
30 lines
735 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 process = node.createProcess(command);
|
|
process.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);
|