Skip to content

Commit a5980da

Browse files
committed
parameters
1 parent b2184c4 commit a5980da

File tree

1 file changed

+40
-37
lines changed

1 file changed

+40
-37
lines changed

src/trials.jl

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,11 @@ Base.show(io::IO, t::TrialJudgement) = _show(io, t)
347347

348348
function Base.show(io::IO, ::MIME"text/plain", t::Trial)
349349
pad = get(io, :pad, "")
350-
padcolor = :light_black
351-
350+
boxcolor = :light_black
351+
boxspace = " "
352+
modulestr = "" # "BenchmarkTools."
353+
avgcolor = :green
354+
medcolor = :blue
352355
showpercentile = 99 # used both for display time, and to set right cutoff of histogram
353356

354357
allocsstr = if allocs(t) == 0
@@ -367,72 +370,74 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)
367370
)
368371

369372
if length(t) == 0
370-
print(io, "BenchmarkTools.Trial: 0 samples")
373+
print(io, modulestr, "Trial: 0 samples")
371374
return
372375
elseif length(t) == 1
373-
printstyled(io, "┌ BenchmarkTools.Trial:\n"; color=padcolor)
376+
printstyled(io, "", modulestr, "Trial:\n"; color=boxcolor)
377+
374378
# Time
375-
printstyled(io, pad, " "; color=padcolor)
379+
printstyled(io, pad, "", boxspace; color=boxcolor)
376380
print(io, "time ")
377-
printstyled(io, prettytime(t.times[1]); color=:green, bold=true)
381+
printstyled(io, prettytime(t.times[1]); color=medcolor, bold=true)
378382

379383
# Memory
380384
println(io)
381-
printstyled(io, pad, " "; color=padcolor)
385+
printstyled(io, pad, "", boxspace; color=boxcolor)
382386
print(io, allocsstr)
383387

384388
# GC time
385389
if t.gctimes[1] > 0
386390
println(io)
387-
printstyled(io, pad, " "; color=padcolor)
391+
printstyled(io, pad, "", boxspace; color=boxcolor)
388392
print(io, "GC time: ", prettytime(t.gctimes[1]))
389-
printstyled(io, " (", prettypercent(t.gctimes[1] / t.times[1]),")"; color=:green)
393+
printstyled(io, " (", prettypercent(t.gctimes[1] / t.times[1]),")"; color=avgcolor)
390394
end
391395

392-
#
396+
# Samples
393397
println(io)
394-
printstyled(io, pad, "", samplesstr; color=padcolor)
398+
printstyled(io, pad, "", boxspace; color=boxcolor)
399+
printstyled(io, samplesstr; color=:light_black)
395400

396401
return
397402
end # done with trivial cases.
398403

399404
# Main text block:
400-
printstyled(io, "BenchmarkTools.Trial:\n"; color=padcolor)
405+
printstyled(io, "", modulestr, "Trial:\n"; color=boxcolor)
401406

402-
printstyled(io, pad, " "; color=padcolor)
407+
printstyled(io, pad, "", boxspace; color=boxcolor)
403408
printstyled(io, "min "; color=:default)
404409
printstyled(io, prettytime(minimum(t.times)); color=:default, bold=true)
405410
print(io, ", ")
406-
printstyled(io, "median "; color=:blue)
407-
printstyled(io, prettytime(median(t.times)); color=:blue, bold=true)
408-
# printstyled(io, " (½)"; color=:blue)
411+
printstyled(io, "median "; color=medcolor)
412+
printstyled(io, prettytime(median(t.times)); color=medcolor, bold=true)
413+
# printstyled(io, " (½)"; color=medcolor)
409414
print(io, ", ")
410-
printstyled(io, "mean "; color=:green)
411-
printstyled(io, prettytime(mean(t.times)); color=:green, bold=true)
412-
# printstyled(io, " (*)"; color=:green)
415+
printstyled(io, "mean "; color=avgcolor)
416+
printstyled(io, prettytime(mean(t.times)); color=avgcolor, bold=true)
417+
# printstyled(io, " (*)"; color=avgcolor)
413418
print(io, ", ")
414419
print(io, showpercentile, "ᵗʰ ")
415420
printstyled(prettytime(quantile(t.times, showpercentile/100)); bold=true)
416421
println(io)
417422

418-
printstyled(io, pad, " "; color=padcolor)
423+
printstyled(io, pad, "", boxspace; color=boxcolor)
419424
println(io, allocsstr)
420425

421426
if !all(iszero, t.gctimes)
422427
# Mean GC time is just that; then we take the percentage of the mean time
423428
avggctime = prettytime(mean(t.gctimes))
424429
avegcpercent = prettypercent(mean(t.gctimes) / mean(t.times))
425430

426-
# Maximum GC time is not taken as the GC time of the slowst run, max(t).
431+
# Maximum GC time is _not_ taken as the GC time of the slowst run, maximum(t).
427432
# The percentage shown is of the same max-GC run, again not the percentage of longest time.
428-
# Of course, very often the slowest run is due to GC, and these concerns won't matter.
433+
# Of course, very often the slowest run is due to GC, and these distinctions won't matter.
429434
_t, _i = findmax(t.gctimes)
430435
maxgctime = prettytime(_t)
431-
maxgcpercent = prettypercent(_t / t.gctimes[_i])
436+
maxgcpercent = prettypercent(_t / t.times[_i])
432437

433-
printstyled(io, pad, " "; color=padcolor)
438+
printstyled(io, pad, "", boxspace; color=boxcolor)
434439
print(io, "GC time: mean ", avggctime)
435-
printstyled(io, " (", avegcpercent, ")"; color=:green)
440+
printstyled(io, " (", avegcpercent, ")"; color=avgcolor)
436441
println(io, ", max ", maxgctime, " (", maxgcpercent, ")")
437442
end
438443

@@ -442,13 +447,11 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)
442447
histquantile = showpercentile/100
443448
# The height and width of the printed histogram in characters:
444449
histheight = 2
445-
histwidth = max(min(90, displaysize(io)[2]), length(samplesstr) + 24) - 8
450+
histwidth = max(min(90, displaysize(io)[2]), length(samplesstr) + 24) - 5 - length(boxspace)
446451
# This should fit it within your terminal, but stops growing at 90 columns. Below about
447452
# 55 columns it will stop shrinking, by which point the first line has already wrapped.
448453

449-
perm = sortperm(t.times)
450-
times = t.times[perm]
451-
gctimes = t.gctimes[perm]
454+
times = sort(t.times)
452455

453456
# This needs sorted times:
454457
histtimes = times[1:round(Int, histquantile*end)]
@@ -489,18 +492,18 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)
489492
# @show q75pos q75pos2
490493

491494
# Above the histogram bars, print markers for special ones:
492-
printstyled(io, pad, " "; color=padcolor)
495+
printstyled(io, pad, "", boxspace; color=boxcolor)
493496
istop = maximum(filter(i -> i in axes(hist,2), [avgpos, medpos+1, q75pos]))
494497
for i in axes(hist, 2)
495498
i > istop && break
496499
if i == avgpos
497-
printstyled(io, "*", color=:green, bold=true)
500+
printstyled(io, "*", color=avgcolor, bold=true)
498501
elseif i == medpos ||
499502
(medpos==avgpos && i==medpos-1 && median(times)<=mean(times)) ||
500503
(medpos==avgpos && i==medpos+1 && median(times)>mean(times))
501504
# marker for "median" is moved one to the left if they collide exactly
502-
# printstyled(io, "½", color=:blue)
503-
printstyled(io, "", color=:blue)
505+
# printstyled(io, "½", color=medcolor)
506+
printstyled(io, "", color=medcolor)
504507
elseif i == q25pos
505508
# printstyled(io, "¼", color=:light_black)
506509
printstyled(io, "", color=:light_black)
@@ -514,15 +517,15 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)
514517

515518
for r in axes(hist, 1)
516519
println(io)
517-
printstyled(io, pad, " "; color=padcolor)
520+
printstyled(io, pad, "", boxspace; color=boxcolor)
518521
istop = findlast(!=(' '), view(hist, r, :))
519522
for (i, bar) in enumerate(view(hist, r, :))
520523
i > istop && break # don't print trailing spaces, as they waste space when line-wrapped
521524
color = :default
522525
if i == avgpos
523-
color = :green
526+
color = avgcolor
524527
elseif i == medpos # if the bars co-incide, colour the mean? matches labels
525-
color = :blue
528+
color = medcolor
526529
elseif bins[i] == 0
527530
color = :light_black
528531
end
@@ -534,7 +537,7 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)
534537
minhisttime, maxhisttime = remtrailingzeros.(prettytime.(round.([histmin, histmax], sigdigits=3)))
535538

536539
println(io)
537-
printstyled(io, pad, " "; color=padcolor)
540+
printstyled(io, pad, "", boxspace; color=boxcolor)
538541
print(io, minhisttime)
539542
# Caption is only printed if logbins has been selected:
540543
caption = logbins ? ("log(counts) from " * samplesstr) : samplesstr

0 commit comments

Comments
 (0)