diff --git a/resources/benchmark.ts b/resources/benchmark.ts index 9524dea748..6f82f19666 100644 --- a/resources/benchmark.ts +++ b/resources/benchmark.ts @@ -381,9 +381,12 @@ function sampleModule(modulePath: string): BenchmarkSample { const sampleCode = ` import fs from 'node:fs'; + import os from 'node:os'; import { benchmark } from '${moduleURL}'; + os.setPriority(os.constants.priority.PRIORITY_HIGHEST); + // warm up, it looks like 7 is a magic number to reliably trigger JIT benchmark.measure(); benchmark.measure(); @@ -414,8 +417,10 @@ function sampleModule(modulePath: string): BenchmarkSample { `; const result = cp.spawnSync( - process.execPath, + 'sudo', [ + '--close-from=4', + `"${process.execPath}"`, // V8 flags '--predictable', '--no-concurrent-sweeping', @@ -427,9 +432,10 @@ function sampleModule(modulePath: string): BenchmarkSample { // Node.js flags '--input-type=module', '--eval', - sampleCode, + `"${sampleCode}"`, ], { + shell: true, stdio: ['inherit', 'inherit', 'inherit', 'pipe'], env: { NODE_ENV: 'production' }, },