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:
authorVse Mozhet Byt <vsemozhetbyt@gmail.com>2017-02-19 19:23:59 +0300
committerJames M Snell <jasnell@gmail.com>2017-03-17 01:52:54 +0300
commit5b1d61ce09023e7a104f28d90d974013381c3591 (patch)
treefe222822abd79d267b71be427d6f04fb86bd477d /benchmark
parent14e3ad0c5ecc092de9fa986a6722e34f55e4d88c (diff)
child_process: fix deoptimizing use of arguments
Removed or fixed use of arguments in execFile(), normalizeExecArgs(), and normalizeSpawnArguments(). Refs: https://github.com/nodejs/node/issues/10323 Refs: https://bugs.chromium.org/p/v8/issues/detail?id=6010 Backport-Of: https://github.com/nodejs/node/pull/11535 PR-URL: https://github.com/nodejs/node/pull/11748 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/child_process/child-process-params.js146
1 files changed, 146 insertions, 0 deletions
diff --git a/benchmark/child_process/child-process-params.js b/benchmark/child_process/child-process-params.js
new file mode 100644
index 00000000000..644b2136a0f
--- /dev/null
+++ b/benchmark/child_process/child-process-params.js
@@ -0,0 +1,146 @@
+'use strict';
+
+const common = require('../common.js');
+const cp = require('child_process');
+
+const command = 'echo';
+const args = ['hello'];
+const options = {};
+const cb = () => {};
+
+const configs = {
+ n: [1e3],
+ methodName: [
+ 'exec', 'execSync',
+ 'execFile', 'execFileSync',
+ 'spawn', 'spawnSync',
+ ],
+ params: [1, 2, 3, 4],
+};
+
+const bench = common.createBenchmark(main, configs);
+
+function main(conf) {
+ const n = +conf.n;
+ const methodName = conf.methodName;
+ const params = +conf.params;
+
+ const method = cp[methodName];
+
+ switch (methodName) {
+ case 'exec':
+ switch (params) {
+ case 1:
+ bench.start();
+ for (let i = 0; i < n; i++) method(command).kill();
+ bench.end(n);
+ break;
+ case 2:
+ bench.start();
+ for (let i = 0; i < n; i++) method(command, options).kill();
+ bench.end(n);
+ break;
+ case 3:
+ bench.start();
+ for (let i = 0; i < n; i++) method(command, options, cb).kill();
+ bench.end(n);
+ break;
+ }
+ break;
+ case 'execSync':
+ switch (params) {
+ case 1:
+ bench.start();
+ for (let i = 0; i < n; i++) method(command);
+ bench.end(n);
+ break;
+ case 2:
+ bench.start();
+ for (let i = 0; i < n; i++) method(command, options);
+ bench.end(n);
+ break;
+ }
+ break;
+ case 'execFile':
+ switch (params) {
+ case 1:
+ bench.start();
+ for (let i = 0; i < n; i++) method(command).kill();
+ bench.end(n);
+ break;
+ case 2:
+ bench.start();
+ for (let i = 0; i < n; i++) method(command, args).kill();
+ bench.end(n);
+ break;
+ case 3:
+ bench.start();
+ for (let i = 0; i < n; i++) method(command, args, options).kill();
+ bench.end(n);
+ break;
+ case 4:
+ bench.start();
+ for (let i = 0; i < n; i++) method(command, args, options, cb).kill();
+ bench.end(n);
+ break;
+ }
+ break;
+ case 'execFileSync':
+ switch (params) {
+ case 1:
+ bench.start();
+ for (let i = 0; i < n; i++) method(command);
+ bench.end(n);
+ break;
+ case 2:
+ bench.start();
+ for (let i = 0; i < n; i++) method(command, args);
+ bench.end(n);
+ break;
+ case 3:
+ bench.start();
+ for (let i = 0; i < n; i++) method(command, args, options);
+ bench.end(n);
+ break;
+ }
+ break;
+ case 'spawn':
+ switch (params) {
+ case 1:
+ bench.start();
+ for (let i = 0; i < n; i++) method(command).kill();
+ bench.end(n);
+ break;
+ case 2:
+ bench.start();
+ for (let i = 0; i < n; i++) method(command, args).kill();
+ bench.end(n);
+ break;
+ case 3:
+ bench.start();
+ for (let i = 0; i < n; i++) method(command, args, options).kill();
+ bench.end(n);
+ break;
+ }
+ break;
+ case 'spawnSync':
+ switch (params) {
+ case 1:
+ bench.start();
+ for (let i = 0; i < n; i++) method(command);
+ bench.end(n);
+ break;
+ case 2:
+ bench.start();
+ for (let i = 0; i < n; i++) method(command, args);
+ bench.end(n);
+ break;
+ case 3:
+ bench.start();
+ for (let i = 0; i < n; i++) method(command, args, options);
+ bench.end(n);
+ break;
+ }
+ break;
+ }
+}