@@ -339,7 +339,12 @@ Base.show(io::IO, t::TrialRatio) = _show(io, t)
339
339
Base. show (io:: IO , t:: TrialJudgement ) = _show (io, t)
340
340
341
341
function Base. show (io:: IO , :: MIME"text/plain" , t:: Trial )
342
- if length (t) > 0
342
+
343
+ pad = get (io, :pad , " " )
344
+ print (io, " BenchmarkTools.Trial: " , length (t), " sample" , if length (t) > 1 " s" else " " end ,
345
+ " with " , t. params. evals, " evaluation" , if t. params. evals > 1 " s" else " " end ," .\n " )
346
+
347
+ if length (t) > 1
343
348
med = median (t)
344
349
avg = mean (t)
345
350
std = Statistics. std (t)
@@ -354,13 +359,20 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)
354
359
355
360
memorystr = string (prettymemory (memory (min)))
356
361
allocsstr = string (allocs (min))
362
+ elseif length (t) == 1
363
+ print (io, pad, " Single result which took " )
364
+ printstyled (io, prettytime (t. times[1 ]); color= :blue )
365
+ print (io, " (" , prettypercent (t. gctimes[1 ]/ t. times[1 ]), " GC) " )
366
+ print (io, " to evaluate,\n " )
367
+ print (io, pad, " with a memory estimate of " )
368
+ printstyled (io, prettymemory (t. memory[1 ]); color= :yellow )
369
+ print (io, " , over " )
370
+ printstyled (io, t. allocs[1 ]; color= :yellow )
371
+ print (io, " allocations." )
372
+ return
357
373
else
358
- medtime, medgc = " N/A" , " N/A"
359
- avgtime, avggc = " N/A" , " N/A"
360
- stdtime, stdgc = " N/A" , " N/A"
361
- mintime, mingc = " N/A" , " N/A"
362
- maxtime, maxgc = " N/A" , " N/A"
363
- memorystr, allocsstr = " N/A" , " N/A"
374
+ print (io, pad, " No results." )
375
+ return
364
376
end
365
377
366
378
lmaxtimewidth = maximum (length .((medtime, avgtime, mintime)))
@@ -370,10 +382,7 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)
370
382
371
383
# Main stats
372
384
373
- pad = get (io, :pad , " " )
374
- print (io, " BenchmarkTools.Trial: " , length (t), " samples with " , t. params. evals, " evaluations." )
375
-
376
- print (io, " \n " , pad, " Range " )
385
+ print (io, pad, " Range " )
377
386
printstyled (io, " (" ; color= :light_black )
378
387
printstyled (io, " min" ; color= :cyan , bold= true )
379
388
print (io, " … " )
@@ -434,12 +443,16 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)
434
443
bins, logbins = log .(1 .+ bins), true
435
444
end
436
445
hist = asciihist (bins, histheight)
437
- hist[end ,end - 1 ] = ' '
446
+ hist[: ,end - 1 ] . = ' '
438
447
maxbin = maximum (bins)
439
448
440
449
delta1 = (histtimes[end ] - histtimes[1 ]) / (histwidth - 1 )
441
- medpos = 1 + round (Int, (histtimes[length (t. times) ÷ 2 ] - histtimes[1 ]) / delta1)
442
- avgpos = 1 + round (Int, (mean (t. times) - histtimes[1 ]) / delta1)
450
+ if delta1 > 0
451
+ medpos = 1 + round (Int, (histtimes[length (t. times) ÷ 2 ] - histtimes[1 ]) / delta1)
452
+ avgpos = 1 + round (Int, (mean (t. times) - histtimes[1 ]) / delta1)
453
+ else
454
+ medpos, avgpos = 1 , 1
455
+ end
443
456
444
457
print (io, " \n " )
445
458
for histrow in eachrow (hist)
0 commit comments