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

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2016-05-15 01:24:34 +0300
committerRich Trott <rtrott@gmail.com>2016-05-25 20:57:59 +0300
commitc9a5990a76ccb15872234948e23bdc12691c2e70 (patch)
tree860e28d73ed7df27216938b3c7a808f74a45eb6b /benchmark/child_process
parent33c7b45378777ddff6dad1a74095d0d8d155f56d (diff)
child_process: measure buffer length in bytes
This change fixes a known issue where `maxBuffer` limits by characters rather than bytes. Benchmark added to confirm no performance regression occurs with this change. PR-URL: https://github.com/nodejs/node/pull/6764 Fixes: https://github.com/nodejs/node/issues/1901 Reviewed-By: Brian White <mscdex@mscdex.net>
Diffstat (limited to 'benchmark/child_process')
-rw-r--r--benchmark/child_process/child-process-exec-stdout.js30
-rw-r--r--benchmark/child_process/child-process-read.js18
2 files changed, 39 insertions, 9 deletions
diff --git a/benchmark/child_process/child-process-exec-stdout.js b/benchmark/child_process/child-process-exec-stdout.js
new file mode 100644
index 00000000000..79efb6fadf2
--- /dev/null
+++ b/benchmark/child_process/child-process-exec-stdout.js
@@ -0,0 +1,30 @@
+'use strict';
+const common = require('../common.js');
+const bench = common.createBenchmark(main, {
+ len: [64, 256, 1024, 4096, 32768],
+ dur: [5]
+});
+
+const exec = require('child_process').exec;
+function main(conf) {
+ bench.start();
+
+ const dur = +conf.dur;
+ const len = +conf.len;
+
+ const msg = `"${'.'.repeat(len)}"`;
+ msg.match(/./);
+ const options = {'stdio': ['ignore', 'pipe', 'ignore']};
+ // NOTE: Command below assumes bash shell.
+ const child = exec(`while\n echo ${msg}\ndo :; done\n`, options);
+
+ var bytes = 0;
+ child.stdout.on('data', function(msg) {
+ bytes += msg.length;
+ });
+
+ setTimeout(function() {
+ child.kill();
+ bench.end(bytes);
+ }, dur * 1000);
+}
diff --git a/benchmark/child_process/child-process-read.js b/benchmark/child_process/child-process-read.js
index c1a7474aae3..33c268390fd 100644
--- a/benchmark/child_process/child-process-read.js
+++ b/benchmark/child_process/child-process-read.js
@@ -1,20 +1,20 @@
'use strict';
-var common = require('../common.js');
-var bench = common.createBenchmark(main, {
+const common = require('../common.js');
+const bench = common.createBenchmark(main, {
len: [64, 256, 1024, 4096, 32768],
dur: [5]
});
-var spawn = require('child_process').spawn;
+const spawn = require('child_process').spawn;
function main(conf) {
bench.start();
- var dur = +conf.dur;
- var len = +conf.len;
+ const dur = +conf.dur;
+ const len = +conf.len;
- var msg = '"' + Array(len).join('.') + '"';
- var options = { 'stdio': ['ignore', 'ipc', 'ignore'] };
- var child = spawn('yes', [msg], options);
+ const msg = '"' + Array(len).join('.') + '"';
+ const options = {'stdio': ['ignore', 'ipc', 'ignore']};
+ const child = spawn('yes', [msg], options);
var bytes = 0;
child.on('message', function(msg) {
@@ -23,7 +23,7 @@ function main(conf) {
setTimeout(function() {
child.kill();
- var gbits = (bytes * 8) / (1024 * 1024 * 1024);
+ const gbits = (bytes * 8) / (1024 * 1024 * 1024);
bench.end(gbits);
}, dur * 1000);
}