summaryrefslogtreecommitdiff
path: root/benchmark/process_loop.js
blob: eeba06ab972cae32cb06d86d11f7954883289e01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var util = require("util"),
    childProcess = require("child_process");

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

  var child = childProcess.spawn("echo", ["hello"]);

  child.stdout.addListener("data", function (chunk) {
    util.print(chunk);
  });

  child.addListener("exit", function (code) {
    if (code != 0) process.exit(-1);
    next(i - 1);
  });
}

next(500);