Skip to content

Commit 5dbb808

Browse files
committed
tools: make v repeat -R 5 -r 10 "v run examples/hello_world.v" also show the time it took for all runs in each repeat
1 parent 23d4754 commit 5dbb808

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎cmd/tools/vrepeat.v‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ mut:
7979
ignore_failed bool // ignore commands that exit with != 0 exit code
8080
no_vexe_setenv bool // do not change the VEXE variable
8181

82-
fail_count map[string]int // how many times a command has failed so far. Only the first failure output is shown.
82+
fail_count map[string]int // how many times a command has failed so far. Only the first failure output is shown.
83+
repeat_timer time.StopWatch = time.new_stopwatch()
8384
}
8485

8586
fn new_aints(ovals []i64, extreme_mins int, extreme_maxs int) Aints {
@@ -198,7 +199,7 @@ fn (mut context Context) run() {
198199
}
199200
if context.warmup > 0 {
200201
for i in 0 .. context.warmup {
201-
flushed_print('${line_prefix}, warm up run: ${i + 1:4}/${context.warmup:-4} took ${f64(duration) / 1000:6.1f}ms ...')
202+
flushed_print('${line_prefix}, warm up run: ${i + 1:4}/${context.warmup:-4}, took: ${f64(duration) / 1000:6.1f}ms ...')
202203
mut sw := time.new_stopwatch()
203204
res := os.execute(cmd)
204205
duration = i64(sw.elapsed().microseconds())
@@ -212,7 +213,7 @@ fn (mut context Context) run() {
212213
if should_show_fail_output {
213214
eprintln('\nCommand exited with exit code: ${res.exit_code} in ${f64(duration) / 1000:6.1f}ms .')
214215
eprintln('Use -e or --ignore to ignore the failed commands.')
215-
eprintln('The failed cmd was: `${cmd}` ; cmd output:')
216+
eprintln('The failed cmd was: `${c(tred, cmd)}` ; cmd output:')
216217
show_failure_output(res.output)
217218
}
218219
}
@@ -233,7 +234,7 @@ fn (mut context Context) run() {
233234
runs++
234235
avg = (f64(sum) / f64(i + 1))
235236
cavg := '${avg / 1000:9.3f}ms'
236-
flushed_print('${line_prefix}, current average: ${c(tgreen, cavg)}, run ${i + 1:4}/${context.run_count:-4} took ${f64(duration) / 1000:6} ms')
237+
flushed_print('${line_prefix}, current average: ${c(tgreen, cavg)}, run ${i + 1:4}/${context.run_count:-4}, took: ${f64(duration) / 1000:6} ms')
237238
if context.show_output {
238239
flushed_print(' | result: ${oldres:s}')
239240
}
@@ -332,7 +333,7 @@ fn (mut context Context) show_diff_summary() {
332333
mut first_marker := ''
333334
if context.results.len == 1 {
334335
gcmd := c(tgreen, context.results[0].cmd)
335-
context.show_summary_title('${context.results[0].atiming}, ${context.series} series, ${context.run_count} runs for ${gcmd:-57s}')
336+
context.show_summary_title('${context.results[0].atiming}, ${context.series} series, ${context.run_count} runs for ${gcmd}')
336337
} else {
337338
context.show_summary_title('Summary after ${context.series} series x ${context.run_count} runs (%s are relative to first command, or `base`)')
338339
for i, r in context.results {
@@ -398,7 +399,8 @@ fn (mut context Context) show_summary_title(line string) {
398399
msg << 'discard maxs: ${context.nmaxs:2}'
399400
}
400401
if context.repeats_count > 1 {
401-
msg << 'repeat: ${context.current_run:2}'
402+
msg << 'repeat: ${context.current_run}/${context.repeats_count}, took: ${f64(context.repeat_timer.elapsed().microseconds()) / 1000:8.3f} ms'
403+
context.repeat_timer.restart()
402404
}
403405
println(msg.join(', '))
404406
}

0 commit comments

Comments
 (0)