summaryrefslogtreecommitdiff
path: root/benchmark/child_process
diff options
context:
space:
mode:
authorAndreas Madsen <amwebdk@gmail.com>2016-01-29 21:40:04 +0100
committerRod Vagg <rod@vagg.org>2016-02-26 20:28:45 +1100
commitd9079ab8013ba2c2a4704a2cca6fe3fcc0a1ecdd (patch)
treeca1875d33a81d5679e96e9be4afce1d2083bc6ac /benchmark/child_process
parent1d7c37018f619ebd4c7d538a4b65461cc447728d (diff)
downloadandroid-node-v8-d9079ab8013ba2c2a4704a2cca6fe3fcc0a1ecdd.tar.gz
android-node-v8-d9079ab8013ba2c2a4704a2cca6fe3fcc0a1ecdd.tar.bz2
android-node-v8-d9079ab8013ba2c2a4704a2cca6fe3fcc0a1ecdd.zip
benchmark: move misc to categorized directories
PR-URL: https://github.com/nodejs/node/pull/5177 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
Diffstat (limited to 'benchmark/child_process')
-rw-r--r--benchmark/child_process/child-process-read.js29
-rw-r--r--benchmark/child_process/spawn-echo.js26
2 files changed, 55 insertions, 0 deletions
diff --git a/benchmark/child_process/child-process-read.js b/benchmark/child_process/child-process-read.js
new file mode 100644
index 0000000000..c1a7474aae
--- /dev/null
+++ b/benchmark/child_process/child-process-read.js
@@ -0,0 +1,29 @@
+'use strict';
+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);
+}
diff --git a/benchmark/child_process/spawn-echo.js b/benchmark/child_process/spawn-echo.js
new file mode 100644
index 0000000000..7c9e851aac
--- /dev/null
+++ b/benchmark/child_process/spawn-echo.js
@@ -0,0 +1,26 @@
+'use strict';
+var common = require('../common.js');
+var bench = common.createBenchmark(main, {
+ thousands: [1]
+});
+
+var spawn = require('child_process').spawn;
+function main(conf) {
+ var len = +conf.thousands * 1000;
+
+ bench.start();
+ go(len, len);
+}
+
+function go(n, left) {
+ if (--left === 0)
+ return bench.end(n);
+
+ var child = spawn('echo', ['hello']);
+ child.on('exit', function(code) {
+ if (code)
+ process.exit(code);
+ else
+ go(n, left);
+ });
+}