|
3 | 3 | const path = require('path'); |
4 | 4 | const { spawn, fork } = require('node:child_process'); |
5 | 5 | const CLI = require('./_cli.js'); |
| 6 | +const { styleText } = require('node:util'); |
6 | 7 |
|
7 | 8 | const cli = new CLI(`usage: ./node run.js [options] [--] <category> ... |
8 | 9 | Run each benchmark in the <category> directory a single time, more than one |
@@ -16,6 +17,7 @@ const cli = new CLI(`usage: ./node run.js [options] [--] <category> ... |
16 | 17 | Default: 1 |
17 | 18 | --set variable=value set benchmark variable (can be repeated) |
18 | 19 | --format [simple|csv] optional value that specifies the output format |
| 20 | + --track Display the time elapsed to run each benchmark file. |
19 | 21 | test only run a single configuration from the options |
20 | 22 | matrix |
21 | 23 | all each benchmark category is run one after the other |
@@ -25,7 +27,7 @@ const cli = new CLI(`usage: ./node run.js [options] [--] <category> ... |
25 | 27 | --set CPUSET=0-2 Specifies that benchmarks should run on CPU cores 0 to 2. |
26 | 28 |
|
27 | 29 | Note: The CPUSET format should match the specifications of the 'taskset' command on your system. |
28 | | -`, { arrayArgs: ['set', 'filter', 'exclude'] }); |
| 30 | +`, { arrayArgs: ['set', 'filter', 'exclude'], boolArgs: ['track'] }); |
29 | 31 |
|
30 | 32 | const benchmarks = cli.benchmarks(); |
31 | 33 |
|
@@ -107,7 +109,12 @@ async function run() { |
107 | 109 | } |
108 | 110 |
|
109 | 111 | while (runs-- > 0) { |
| 112 | + const start = performance.now(); |
110 | 113 | await runBenchmark(filename); |
| 114 | + if (format !== 'csv' && cli.optional.track) { |
| 115 | + const ms = styleText(['bold', 'yellow'], `${Math.round(performance.now() - start)}ms`); |
| 116 | + console.log(`[${ms}] ${filename}`); |
| 117 | + } |
111 | 118 | } |
112 | 119 | } |
113 | 120 | } |
|