Skip to content

Commit fb32951

Browse files
committed
tools: make the summary output of v repeat more informative
1 parent 041f2b3 commit fb32951

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

cmd/tools/vrepeat.v

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ fn (a Aints) str() string {
113113
baseline := '${avg} ± σ: ${tdev},'
114114
tmin := term.colorize(term.bright_cyan, '${f64(a.imin) / 1000:5.1f}ms')
115115
tmax := term.colorize(term.bright_blue, '${f64(a.imax) / 1000:5.1f}ms')
116-
return '${baseline:-46s} ${tmin}${tmax}'
116+
return '${baseline:-46s} ${tmin}${tmax}'
117117
}
118118

119119
fn flushed_print(s string) {
@@ -288,22 +288,31 @@ fn (mut context Context) show_diff_summary() {
288288
mut first_cmd_percentage := f64(100.0)
289289
mut first_marker := ''
290290
if context.results.len == 1 {
291-
context.show_summary_title('${term.colorize(term.yellow, context.results[0].cmd):-57s}\n${context.results[0].atiming}, ${context.series} series, ${context.run_count} runs')
291+
context.show_summary_title('${context.results[0].atiming}, ${context.series} series, ${context.run_count} runs for ${term.colorize(term.green,
292+
context.results[0].cmd):-57s}')
292293
} else {
293-
context.show_summary_title('Summary after ${context.series} series x ${context.run_count} runs (`>` is the first cmd)')
294+
context.show_summary_title('Summary after ${context.series} series x ${context.run_count} runs (%s are relative to first command, or `base`).')
294295
for i, r in context.results {
295296
first_marker = ' '
296297
cpercent := (r.atiming.average / base) * 100 - 100
297298
if r.icmd == 0 {
298299
first_marker = bold('>')
299300
first_cmd_percentage = cpercent
300301
}
301-
mut comparison := '==='
302+
mut comparison := ''
302303
if r.atiming.average != base {
303-
comparison = '${cpercent:+7.1f}%'
304+
comparison = '${cpercent:+6.1f}%'
304305
}
305-
println(' ${first_marker}${(i + 1):3} ${comparison:9} `${r.cmd}`')
306-
println(' ${r.atiming}')
306+
mut tcomparison := 'base '
307+
if r.atiming.average != base {
308+
if r.atiming.average < base {
309+
tcomparison = '${base / r.atiming.average:4.2f}x faster'
310+
} else {
311+
tcomparison = '${r.atiming.average / base:4.2f}x slower'
312+
}
313+
}
314+
println(' ${first_marker}${(i + 1):3} ${comparison:7} ${tcomparison:5} ${r.atiming} `${term.colorize(term.green,
315+
r.cmd)}`')
307316
}
308317
}
309318
$if debugcontext ? {

0 commit comments

Comments
 (0)