summaryrefslogtreecommitdiff
path: root/benchmark/run.js
diff options
context:
space:
mode:
authorRyan <ry@tinyclouds.org>2009-07-13 12:48:59 +0200
committerRyan <ry@tinyclouds.org>2009-07-13 16:38:55 +0200
commit05d6319fa034b8ef4d26445c59e3049bde3c41fb (patch)
tree6dc6f7445c40aea48af8e0b4575fc1d74e12ea13 /benchmark/run.js
parentbf6a457f64d44fbd3cdd273559cad5dafd16676e (diff)
downloadnode-new-05d6319fa034b8ef4d26445c59e3049bde3c41fb.tar.gz
Add benchmark scripts.
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.
Diffstat (limited to 'benchmark/run.js')
-rw-r--r--benchmark/run.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/benchmark/run.js b/benchmark/run.js
new file mode 100644
index 0000000000..4bb2f5c4db
--- /dev/null
+++ b/benchmark/run.js
@@ -0,0 +1,29 @@
+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);