|
1 | 1 | 'use strict';
|
2 | 2 |
|
3 |
| -const { spawn } = require('child_process'); |
| 3 | +const { spawn, fork } = require('child_process'); |
4 | 4 | const { inspect } = require('util');
|
5 | 5 | const path = require('path');
|
6 | 6 | const CLI = require('./_cli.js');
|
@@ -41,7 +41,7 @@ if (benchmarks.length === 0) {
|
41 | 41 | }
|
42 | 42 |
|
43 | 43 | const cpuCoreSetting = cli.optional.set.find(s => s.startsWith('CPUCORE='));
|
44 |
| -let cpuCore = '0'; |
| 44 | +let cpuCore = null; |
45 | 45 | if (cpuCoreSetting) {
|
46 | 46 | cpuCore = cpuCoreSetting.split('=')[1];
|
47 | 47 | }
|
@@ -76,12 +76,23 @@ if (showProgress) {
|
76 | 76 | (function recursive(i) {
|
77 | 77 | const job = queue[i];
|
78 | 78 |
|
79 |
| - const spawnArgs = ['-c', cpuCore, cli.optional[job.binary], path.resolve(__dirname, job.filename), ...cli.optional.set]; |
80 |
| - |
81 |
| - const child = spawn('taskset', spawnArgs, { |
82 |
| - env: process.env, |
83 |
| - stdio: ['inherit', 'pipe', 'inherit', 'ipc'], |
84 |
| - }); |
| 79 | + const resolvedPath = path.resolve(__dirname, job.filename); |
| 80 | + let child; |
| 81 | + if (cpuCore !== null) { |
| 82 | + const spawnArgs = ['-c', cpuCore, cli.optional[job.binary], resolvedPath, ...cli.optional.set]; |
| 83 | + child = spawn('taskset', spawnArgs, { |
| 84 | + env: process.env, |
| 85 | + stdio: ['inherit', 'pipe', 'ipc'], |
| 86 | + }); |
| 87 | + |
| 88 | + child.stdout.on('data', (data) => { |
| 89 | + process.stdout.write(data); |
| 90 | + }); |
| 91 | + } else { |
| 92 | + child = fork(resolvedPath, cli.optional.set, { |
| 93 | + execPath: cli.optional[job.binary], |
| 94 | + }); |
| 95 | + } |
85 | 96 |
|
86 | 97 | child.on('message', (data) => {
|
87 | 98 | if (data.type === 'report') {
|
|
0 commit comments