MCPcopy Index your code
hub / github.com/nodejs/node / _run

Method _run

benchmark/common.js:200–251  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

198 }
199
200 _run() {
201 // If forked, report to the parent.
202 if (process.send) {
203 process.send({
204 type: 'config',
205 name: this.name,
206 queueLength: this.queue.length,
207 });
208 }
209
210 if (this.originalOptions.setup) {
211 // Only do this from the root process. _run() is only ever called from the root,
212 // in child processes main is run directly.
213 this.originalOptions.setup(this.queue);
214 }
215
216 const recursive = (queueIndex) => {
217 const config = this.queue[queueIndex];
218
219 // Set NODE_RUN_BENCHMARK_FN to indicate that the child shouldn't
220 // construct a configuration queue, but just execute the benchmark
221 // function.
222 const childEnv = { ...process.env };
223 childEnv.NODE_RUN_BENCHMARK_FN = '';
224
225 // Create configuration arguments
226 const childArgs = [];
227 for (const [key, value] of Object.entries(config)) {
228 childArgs.push(`${key}=${value}`);
229 }
230 for (const [key, value] of Object.entries(this.extra_options)) {
231 childArgs.push(`${key}=${value}`);
232 }
233
234 const child = child_process.fork(require.main.filename, childArgs, {
235 env: childEnv,
236 execArgv: this.flags.concat(process.execArgv),
237 });
238 child.on('message', sendResult);
239 child.on('close', (code) => {
240 if (code) {
241 process.exit(code);
242 }
243
244 if (queueIndex + 1 < this.queue.length) {
245 recursive(queueIndex + 1);
246 }
247 });
248 };
249
250 recursive(0);
251 }
252
253 start() {
254 if (this._started) {

Callers 1

constructorMethod · 0.95

Calls 3

sendMethod · 0.65
recursiveFunction · 0.50
setupMethod · 0.45

Tested by

no test coverage detected