Skip to content

Commit acf7f8c

Browse files
committed
Add CLI aliases for dump and check modes and throw when both are provided
1 parent 152396c commit acf7f8c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/lib/testing/perf-regression.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99
*
1010
* For regression testing of constraint systems (CS) and zkApps,
1111
* see {@link tests/perf-regression/perf-regression.ts}.
12+
*
13+
* @note
14+
* Command-line arguments:
15+
* - `--dump` (alias `-d`): dump performance data into the baseline file.
16+
* - `--check` (alias `-c`): check performance against the existing baseline.
17+
* - `--file` (alias `-f`): specify a custom JSON path (default: `./tests/perf-regression/perf-regression.json`).
18+
* - `--silent`: suppress all console output.
19+
*
20+
* These flags are mutually exclusive for modes (`--dump` and `--check` cannot be used together).
21+
* When neither is provided, the script runs in log-only mode.
1222
*/
1323

1424
import { ConstraintSystemSummary } from '../provable/core/provable-context.js';
@@ -44,13 +54,23 @@ type PerfStack = {
4454
const argv = minimist(process.argv.slice(2), {
4555
boolean: ['dump', 'check', 'silent'],
4656
string: ['file'],
47-
alias: { f: 'file' },
57+
alias: {
58+
f: 'file',
59+
d: 'dump',
60+
c: 'check',
61+
},
4862
});
4963

5064
const DUMP = Boolean(argv.dump);
5165
const CHECK = Boolean(argv.check);
5266
const SILENT = Boolean(argv.silent);
5367

68+
// Cannot use both dump and check
69+
if (DUMP && CHECK) {
70+
console.error('Error: You cannot use both --dump and --check at the same time!');
71+
process.exit(1);
72+
}
73+
5474
const FILE_PATH = path.isAbsolute(argv.file ?? '')
5575
? argv.file
5676
: path.join(

0 commit comments

Comments
 (0)