Welcome to mirror list, hosted at ThFree Co, Russian Federation.

child-process-read.js « misc « benchmark - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 894dd55d301249c9858a0f31f42400136f25dbe2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var common = require('../common.js');
var bench = common.createBenchmark(main, {
  len: [64, 256, 1024, 4096, 32768],
  dur: [5]
});

var spawn = require('child_process').spawn;
function main(conf) {
  bench.start();

  var dur = +conf.dur;
  var len = +conf.len;

  var msg = '"' + Array(len).join('.') + '"';
  var options = { 'stdio': ['ignore', 'ipc', 'ignore'] };
  var child = spawn('yes', [msg], options);

  var bytes = 0;
  child.on('message', function(msg) {
    bytes += msg.length;
  });

  setTimeout(function() {
    child.kill();
    var gbits = (bytes * 8) / (1024 * 1024 * 1024);
    bench.end(gbits);
  }, dur * 1000);
}