From fb6dc11f112b7b6ec989d5fa882d094327e8fdf3 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 8 Mar 2010 19:06:25 -0800 Subject: [PATCH] Clean up some things in the benchmarks --- benchmark/process_loop.js | 9 +++------ benchmark/run.js | 15 ++++++--------- benchmark/static_http_server.js | 6 ++---- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/benchmark/process_loop.js b/benchmark/process_loop.js index 0ee61b76a2b..55ad6c44958 100644 --- a/benchmark/process_loop.js +++ b/benchmark/process_loop.js @@ -1,15 +1,12 @@ -var path = require("path"); -libDir = path.join(path.dirname(__filename), "../lib"); -require.paths.unshift(libDir); -var sys = (require("sys")); -for (var i in sys) global[i] = sys[i]; +var sys = require("../lib/sys"); + function next (i) { if (i <= 0) return; var child = process.createChildProcess("echo", ["hello"]); child.addListener("output", function (chunk) { - if (chunk) print(chunk); + if (chunk) sys.print(chunk); }); child.addListener("exit", function (code) { diff --git a/benchmark/run.js b/benchmark/run.js index 60b7752c7a5..b1ab79ecc1f 100644 --- a/benchmark/run.js +++ b/benchmark/run.js @@ -1,18 +1,15 @@ var path = require("path"); -libDir = path.join(path.dirname(__filename), "../lib"); -require.paths.unshift(libDir); -var sys = (require("sys")); -for (var i in sys) global[i] = sys[i]; +var sys = require("../lib/sys"); var benchmarks = [ "static_http_server.js" , "timers.js" , "process_loop.js" ]; -var benchmark_dir = path.dirname(__filename); +var benchmarkDir = path.dirname(__filename); function exec (script, callback) { var start = new Date(); - var child = process.createChildProcess(process.ARGV[0], [path.join(benchmark_dir, script)]); + var child = process.createChildProcess(process.ARGV[0], [path.join(benchmarkDir, script)]); child.addListener("exit", function (code) { var elapsed = new Date() - start; callback(elapsed, code); @@ -21,12 +18,12 @@ function exec (script, callback) { function runNext (i) { if (i >= benchmarks.length) return; - print(benchmarks[i] + ": "); + sys.print(benchmarks[i] + ": "); exec(benchmarks[i], function (elapsed, code) { if (code != 0) { - puts("ERROR "); + sys.puts("ERROR "); } - puts(elapsed); + sys.puts(elapsed); runNext(i+1); }); }; diff --git a/benchmark/static_http_server.js b/benchmark/static_http_server.js index 5b4f220ba8c..398b9bf204c 100644 --- a/benchmark/static_http_server.js +++ b/benchmark/static_http_server.js @@ -1,7 +1,5 @@ -var path = require("path"); -libDir = path.join(path.dirname(__filename), "../lib"); -require.paths.unshift(libDir); -http = require("http"); +var http = require("../lib/http"); + var concurrency = 30; var port = 8000; var n = 700;