Skip to content

Commit 6f84063

Browse files
arlolrary
authored andcommitted
Migrates benchmarks to the new api.
1 parent 54d4efd commit 6f84063

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

benchmark/process_loop.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
var sys = require("../lib/sys");
1+
var sys = require("sys"),
2+
childProcess = require("child_process");
23

34
function next (i) {
45
if (i <= 0) return;
56

6-
var child = process.createChildProcess("echo", ["hello"]);
7+
var child = childProcess.spawn("echo", ["hello"]);
78

8-
child.addListener("output", function (chunk) {
9-
if (chunk) sys.print(chunk);
9+
child.stdout.addListener("data", function (chunk) {
10+
sys.print(chunk);
1011
});
1112

1213
child.addListener("exit", function (code) {

benchmark/run.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
var path = require("path");
2-
var sys = require("../lib/sys");
3-
var benchmarks = [ "static_http_server.js"
4-
, "timers.js"
2+
var sys = require("sys");
3+
var childProcess = require("child_process");
4+
var benchmarks = [ "timers.js"
55
, "process_loop.js"
6+
, "static_http_server.js"
67
];
78

89
var benchmarkDir = path.dirname(__filename);
910

1011
function exec (script, callback) {
1112
var start = new Date();
12-
var child = process.createChildProcess(process.ARGV[0], [path.join(benchmarkDir, script)]);
13+
var child = childProcess.spawn(process.argv[0], [path.join(benchmarkDir, script)]);
1314
child.addListener("exit", function (code) {
1415
var elapsed = new Date() - start;
1516
callback(elapsed, code);

benchmark/static_http_server.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
var http = require("../lib/http");
1+
var http = require("http");
22

33
var concurrency = 30;
4-
var port = 8000;
5-
var n = 700;
4+
var port = 12346;
5+
var n = 7; // several orders of magnitude slower
66
var bytes = 1024*5;
77

88
var requests = 0;

0 commit comments

Comments
 (0)