50
50
struct Context {
51
51
mut :
52
52
run_count int
53
+ repeats_count int
54
+ current_run int
53
55
series int
54
56
warmup int
55
57
show_help bool
@@ -309,7 +311,7 @@ fn (mut context Context) show_diff_summary() {
309
311
gcmd := c (tgreen, context.results[0 ].cmd)
310
312
context.show_summary_title ('${context.results[0].atiming} , ${context.series} series, ${context.run_count} runs for ${gcmd:-57s} ' )
311
313
} else {
312
- context.show_summary_title ('Summary after ${context.series} series x ${context.run_count} runs (%s are relative to first command, or `base`). ' )
314
+ context.show_summary_title ('Summary after ${context.series} series x ${context.run_count} runs (%s are relative to first command, or `base`)' )
313
315
for i, r in context.results {
314
316
first_marker = ' '
315
317
cpercent := (r.atiming.average / base) * 100 - 100
@@ -360,6 +362,9 @@ fn (mut context Context) show_summary_title(line string) {
360
362
if context.nmaxs > 0 {
361
363
msg << 'discard maxs: ${context.nmaxs:2} '
362
364
}
365
+ if context.current_run > 0 {
366
+ msg << 'repeat: ${context.current_run:2} '
367
+ }
363
368
println (msg.join (', ' ))
364
369
}
365
370
@@ -373,6 +378,7 @@ fn (mut context Context) parse_options() ! {
373
378
fp.limit_free_args_to_at_least (1 )!
374
379
context.show_help = fp.bool ('help' , `h` , false , 'Show this help screen.' )
375
380
context.run_count = fp.int ('runs' , `r` , 10 , 'Run count. Default: 10' )
381
+ context.repeats_count = fp.int ('repeats' , `R` , 1 , 'Repeats count (it repeats everything, including reporting). Default: 1' )
376
382
context.warmup = fp.int ('warmup' , `w` , 2 , 'Warmup run count. These are done *at the start* of each series, and the timings are ignored. Default: 2' )
377
383
context.series = fp.int ('series' , `s` , 1 , 'Series count. `-s 2 -r 4 a b` => aaaabbbbaaaabbbb, while `-s 3 -r 2 a b` => aabbaabbaabb. Default: 1' )
378
384
context.ignore_failed = fp.bool ('ignore' , `e` , false , 'Ignore failed commands (returning a non 0 exit code).' )
@@ -400,10 +406,7 @@ fn (mut context Context) parse_options() ! {
400
406
exit (1 )
401
407
}
402
408
context.commands = context.expand_all_commands (commands)
403
- context.results = []CmdResult{len: context.commands.len, cap: 20 , init: CmdResult{
404
- outputs: []string {cap: 500 }
405
- timings: []i64 {cap: 500 }
406
- }}
409
+ context.reset_results ()
407
410
if context.use_newline {
408
411
context.cline = '\n '
409
412
context.cgoback = '\n '
@@ -413,12 +416,23 @@ fn (mut context Context) parse_options() ! {
413
416
}
414
417
}
415
418
419
+ fn (mut context Context) reset_results () {
420
+ context.results = []CmdResult{len: context.commands.len, cap: 20 , init: CmdResult{
421
+ outputs: []string {cap: 500 }
422
+ timings: []i64 {cap: 500 }
423
+ }}
424
+ }
425
+
416
426
fn main () {
417
427
// Make sure that we can measure various V executables
418
428
// without influencing them, by presetting VEXE
419
429
os.setenv ('VEXE' , '' , true )
420
430
mut context := Context{}
421
431
context.parse_options ()!
422
- context.run ()
423
- context.show_diff_summary ()
432
+ for i := 1 ; i < = context.repeats_count; i++ {
433
+ context.current_run = i
434
+ context.reset_results ()
435
+ context.run ()
436
+ context.show_diff_summary ()
437
+ }
424
438
}
0 commit comments