Skip to content

Commit 1777bcc

Browse files
committed
tools: improve the help screen for v repeat -h, add detailed example for using -t and -p to produce a matrix of 24 permutation runs
1 parent 7baee04 commit 1777bcc

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

cmd/tools/vrepeat.v

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn (mut context Context) expand_all_commands(commands []string) []string {
148148
for paramv in paramlist {
149149
mut new_substituted_commands := []string{}
150150
for cscmd in substituted_commands {
151-
scmd := cscmd.replace(paramk, paramv)
151+
scmd := cscmd.replace('{${paramk}}', paramv)
152152
new_substituted_commands << scmd
153153
}
154154
for sc in new_substituted_commands {
@@ -297,6 +297,10 @@ fn compare_by_average(a &CmdResult, b &CmdResult) int {
297297
}
298298

299299
fn (mut context Context) show_diff_summary() {
300+
if context.results.len == 0 {
301+
eprintln('no results')
302+
exit(5)
303+
}
300304
base := context.results[0].atiming.average
301305
context.results.sort_with_compare(compare_by_average)
302306
mut first_cmd_percentage := f64(100.0)
@@ -362,7 +366,7 @@ fn (mut context Context) show_summary_title(line string) {
362366
fn (mut context Context) parse_options() ! {
363367
mut fp := flag.new_flag_parser(os.args#[1..])
364368
fp.application(os.file_name(os.executable()))
365-
fp.version('0.0.2')
369+
fp.version('0.0.3')
366370
fp.description('Repeat command(s) and collect statistics.\nNote: quote each command (argument), when it contains spaces.')
367371
fp.arguments_description('CMD1 CMD2 ...')
368372
fp.skip_executable()
@@ -377,14 +381,14 @@ fn (mut context Context) parse_options() ! {
377381
context.verbose = fp.bool('verbose', `v`, false, 'Be more verbose.')
378382
context.fail_on_maxtime = fp.int('max_time', `m`, max_time, 'Fail with exit code 2, when first cmd takes above M milliseconds (regression). Default: ${max_time}')
379383
context.fail_on_regress_percent = fp.int('fail_percent', `f`, max_fail_percent, 'Fail with exit code 3, when first cmd is X% slower than the rest (regression). Default: ${max_fail_percent}')
380-
context.cmd_template = fp.string('template', `t`, '{T}', 'Command template. {T} will be substituted with the current command. Default: {T}')
381-
cmd_params := fp.string_multi('parameter', `p`, 'A parameter substitution list. `{p}=val1,val2,val2` means that {p} in the template, will be substituted with each of val1, val2, val3.')
384+
context.cmd_template = fp.string('template', `t`, '{T}', 'Command template. {T} will be substituted with the current command. Default: {T}. \n Here is an example, that will produce and run 24 permutations = (3 for opt) x (2 for source) x (4 = v names):\n v repeat -p opt=-check-syntax,-check,"-o x.c" -p source=examples/hello_world.v,examples/hanoi.v --template "./{T} {opt} {source}" vold vnew vold_prod vnew_prod')
385+
cmd_params := fp.string_multi('parameter', `p`, 'A parameter substitution list. `pp=val1,val2,val2` means that {pp} in the template, will be substituted with *each* of val1, val2, val3.')
382386
context.nmins = fp.int('nmins', `i`, 0, 'Ignore the BOTTOM X results (minimum execution time). Makes the results more robust to performance flukes. Default: 0')
383387
context.nmaxs = fp.int('nmaxs', `a`, 0, 'Ignore the TOP X results (maximum execution time). Makes the results more robust to performance flukes. Default: 0')
384388
for p in cmd_params {
385-
parts := p.split(':')
389+
parts := p.split('=')
386390
if parts.len > 1 {
387-
context.cmd_params[parts[0]] = parts[1].split(',')
391+
context.cmd_params[parts[0].trim('{}')] = parts[1].split(',')
388392
}
389393
}
390394
if context.show_help {

0 commit comments

Comments
 (0)