@@ -347,8 +347,11 @@ Base.show(io::IO, t::TrialJudgement) = _show(io, t)
347
347
348
348
function Base. show (io:: IO , :: MIME"text/plain" , t:: Trial )
349
349
pad = get (io, :pad , " " )
350
- padcolor = :light_black
351
-
350
+ boxcolor = :light_black
351
+ boxspace = " "
352
+ modulestr = " " # "BenchmarkTools."
353
+ avgcolor = :green
354
+ medcolor = :blue
352
355
showpercentile = 99 # used both for display time, and to set right cutoff of histogram
353
356
354
357
allocsstr = if allocs (t) == 0
@@ -367,72 +370,74 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)
367
370
)
368
371
369
372
if length (t) == 0
370
- print (io, " BenchmarkTools. Trial: 0 samples" )
373
+ print (io, modulestr, " Trial: 0 samples" )
371
374
return
372
375
elseif length (t) == 1
373
- printstyled (io, " ┌ BenchmarkTools.Trial:\n " ; color= padcolor)
376
+ printstyled (io, " ┌ " , modulestr, " Trial:\n " ; color= boxcolor)
377
+
374
378
# Time
375
- printstyled (io, pad, " │ " ; color= padcolor )
379
+ printstyled (io, pad, " │" , boxspace ; color= boxcolor )
376
380
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 )
378
382
379
383
# Memory
380
384
println (io)
381
- printstyled (io, pad, " │ " ; color= padcolor )
385
+ printstyled (io, pad, " │" , boxspace ; color= boxcolor )
382
386
print (io, allocsstr)
383
387
384
388
# GC time
385
389
if t. gctimes[1 ] > 0
386
390
println (io)
387
- printstyled (io, pad, " │ " ; color= padcolor )
391
+ printstyled (io, pad, " │" , boxspace ; color= boxcolor )
388
392
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 )
390
394
end
391
395
392
- #
396
+ # Samples
393
397
println (io)
394
- printstyled (io, pad, " └ " , samplesstr; color= padcolor)
398
+ printstyled (io, pad, " └" , boxspace; color= boxcolor)
399
+ printstyled (io, samplesstr; color= :light_black )
395
400
396
401
return
397
402
end # done with trivial cases.
398
403
399
404
# Main text block:
400
- printstyled (io, " ┌ BenchmarkTools. Trial:\n " ; color= padcolor )
405
+ printstyled (io, " ┌ " , modulestr, " Trial:\n " ; color= boxcolor )
401
406
402
- printstyled (io, pad, " │ " ; color= padcolor )
407
+ printstyled (io, pad, " │" , boxspace ; color= boxcolor )
403
408
printstyled (io, " min " ; color= :default )
404
409
printstyled (io, prettytime (minimum (t. times)); color= :default , bold= true )
405
410
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 )
409
414
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 )
413
418
print (io, " , " )
414
419
print (io, showpercentile, " ᵗʰ " )
415
420
printstyled (prettytime (quantile (t. times, showpercentile/ 100 )); bold= true )
416
421
println (io)
417
422
418
- printstyled (io, pad, " │ " ; color= padcolor )
423
+ printstyled (io, pad, " │" , boxspace ; color= boxcolor )
419
424
println (io, allocsstr)
420
425
421
426
if ! all (iszero, t. gctimes)
422
427
# Mean GC time is just that; then we take the percentage of the mean time
423
428
avggctime = prettytime (mean (t. gctimes))
424
429
avegcpercent = prettypercent (mean (t. gctimes) / mean (t. times))
425
430
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).
427
432
# 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.
429
434
_t, _i = findmax (t. gctimes)
430
435
maxgctime = prettytime (_t)
431
- maxgcpercent = prettypercent (_t / t. gctimes [_i])
436
+ maxgcpercent = prettypercent (_t / t. times [_i])
432
437
433
- printstyled (io, pad, " │ " ; color= padcolor )
438
+ printstyled (io, pad, " │" , boxspace ; color= boxcolor )
434
439
print (io, " GC time: mean " , avggctime)
435
- printstyled (io, " (" , avegcpercent, " )" ; color= :green )
440
+ printstyled (io, " (" , avegcpercent, " )" ; color= avgcolor )
436
441
println (io, " , max " , maxgctime, " (" , maxgcpercent, " )" )
437
442
end
438
443
@@ -442,13 +447,11 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)
442
447
histquantile = showpercentile/ 100
443
448
# The height and width of the printed histogram in characters:
444
449
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)
446
451
# This should fit it within your terminal, but stops growing at 90 columns. Below about
447
452
# 55 columns it will stop shrinking, by which point the first line has already wrapped.
448
453
449
- perm = sortperm (t. times)
450
- times = t. times[perm]
451
- gctimes = t. gctimes[perm]
454
+ times = sort (t. times)
452
455
453
456
# This needs sorted times:
454
457
histtimes = times[1 : round (Int, histquantile* end )]
@@ -489,18 +492,18 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)
489
492
# @show q75pos q75pos2
490
493
491
494
# Above the histogram bars, print markers for special ones:
492
- printstyled (io, pad, " │ " ; color= padcolor )
495
+ printstyled (io, pad, " │" , boxspace ; color= boxcolor )
493
496
istop = maximum (filter (i -> i in axes (hist,2 ), [avgpos, medpos+ 1 , q75pos]))
494
497
for i in axes (hist, 2 )
495
498
i > istop && break
496
499
if i == avgpos
497
- printstyled (io, " *" , color= :green , bold= true )
500
+ printstyled (io, " *" , color= avgcolor , bold= true )
498
501
elseif i == medpos ||
499
502
(medpos== avgpos && i== medpos- 1 && median (times)<= mean (times)) ||
500
503
(medpos== avgpos && i== medpos+ 1 && median (times)> mean (times))
501
504
# 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 )
504
507
elseif i == q25pos
505
508
# printstyled(io, "¼", color=:light_black)
506
509
printstyled (io, " ◔" , color= :light_black )
@@ -514,15 +517,15 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)
514
517
515
518
for r in axes (hist, 1 )
516
519
println (io)
517
- printstyled (io, pad, " │ " ; color= padcolor )
520
+ printstyled (io, pad, " │" , boxspace ; color= boxcolor )
518
521
istop = findlast (!= (' ' ), view (hist, r, :))
519
522
for (i, bar) in enumerate (view (hist, r, :))
520
523
i > istop && break # don't print trailing spaces, as they waste space when line-wrapped
521
524
color = :default
522
525
if i == avgpos
523
- color = :green
526
+ color = avgcolor
524
527
elseif i == medpos # if the bars co-incide, colour the mean? matches labels
525
- color = :blue
528
+ color = medcolor
526
529
elseif bins[i] == 0
527
530
color = :light_black
528
531
end
@@ -534,7 +537,7 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)
534
537
minhisttime, maxhisttime = remtrailingzeros .(prettytime .(round .([histmin, histmax], sigdigits= 3 )))
535
538
536
539
println (io)
537
- printstyled (io, pad, " └ " ; color= padcolor )
540
+ printstyled (io, pad, " └" , boxspace ; color= boxcolor )
538
541
print (io, minhisttime)
539
542
# Caption is only printed if logbins has been selected:
540
543
caption = logbins ? (" log(counts) from " * samplesstr) : samplesstr
0 commit comments