--bench


稳定性: 1 - 实验性

启动 Node.js 命令行基准测试运行器。至少需要一个明确的文件或通配符模式:

🌐 Starts the Node.js command-line benchmark runner. At least one explicit file or glob pattern is required:

node --experimental-bench --bench benchmark.mjs
node --experimental-bench --bench 'benchmarks/**/*.js' 

要使用这个标志或任何其他 --bench-* 选项,需要 --experimental-bench 标志。

🌐 The --experimental-bench flag is required to use this flag or any other --bench-* option.

给全局模式加引号以防止被 shell 展开。匹配的文件会被排序并依次执行。默认情况下,每个文件都会在单独的子进程中运行。基准测试文件使用 node:bench 来声明基准测试;它们自己不能调用 run()。更多细节请参见 基准测试运行器 文档。

🌐 Quote glob patterns to prevent expansion by the shell. Matching files are sorted and executed serially. By default, each file runs in a separate child process. Benchmark files declare benchmarks using node:bench; they must not call run() themselves. See the benchmark runner documentation for more details.

这个标志不能与 --test、--watch、--watch-path、--check、--eval 或 --interactive 组合使用。

🌐 This flag cannot be combined with --test, --watch, --watch-path, --check, --eval, or --interactive.