Browse Source

Migrates benchmarks to the new api.

v0.7.4-release
arlolra 15 years ago
committed by Ryan Dahl
parent
commit
6f84063a3b
  1. 9
      benchmark/process_loop.js
  2. 9
      benchmark/run.js
  3. 6
      benchmark/static_http_server.js

9
benchmark/process_loop.js

@ -1,12 +1,13 @@
var sys = require("../lib/sys"); var sys = require("sys"),
childProcess = require("child_process");
function next (i) { function next (i) {
if (i <= 0) return; if (i <= 0) return;
var child = process.createChildProcess("echo", ["hello"]); var child = childProcess.spawn("echo", ["hello"]);
child.addListener("output", function (chunk) { child.stdout.addListener("data", function (chunk) {
if (chunk) sys.print(chunk); sys.print(chunk);
}); });
child.addListener("exit", function (code) { child.addListener("exit", function (code) {

9
benchmark/run.js

@ -1,15 +1,16 @@
var path = require("path"); var path = require("path");
var sys = require("../lib/sys"); var sys = require("sys");
var benchmarks = [ "static_http_server.js" var childProcess = require("child_process");
, "timers.js" var benchmarks = [ "timers.js"
, "process_loop.js" , "process_loop.js"
, "static_http_server.js"
]; ];
var benchmarkDir = path.dirname(__filename); var benchmarkDir = path.dirname(__filename);
function exec (script, callback) { function exec (script, callback) {
var start = new Date(); var start = new Date();
var child = process.createChildProcess(process.ARGV[0], [path.join(benchmarkDir, script)]); var child = childProcess.spawn(process.argv[0], [path.join(benchmarkDir, script)]);
child.addListener("exit", function (code) { child.addListener("exit", function (code) {
var elapsed = new Date() - start; var elapsed = new Date() - start;
callback(elapsed, code); callback(elapsed, code);

6
benchmark/static_http_server.js

@ -1,8 +1,8 @@
var http = require("../lib/http"); var http = require("http");
var concurrency = 30; var concurrency = 30;
var port = 8000; var port = 12346;
var n = 700; var n = 7; // several orders of magnitude slower
var bytes = 1024*5; var bytes = 1024*5;
var requests = 0; var requests = 0;

Loading…
Cancel
Save