From 2358184f4a37ca3419c8edf2db418edb13b69963 Mon Sep 17 00:00:00 2001 From: Colin Caine Date: Fri, 9 Jul 2021 12:15:18 +0100 Subject: [PATCH] Highlight the correct bins in histograms See https://github.com/JuliaCI/BenchmarkTools.jl/pull/217#discussion_r666788268 --- src/trials.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/trials.jl b/src/trials.jl index b23026ab..2f748b78 100644 --- a/src/trials.jl +++ b/src/trials.jl @@ -422,11 +422,11 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial) # Histogram histquantile = 0.99 + # The height and width of the printed histogram in characters. histheight = 2 histwidth = 42 + lmaxtimewidth + rmaxtimewidth histtimes = t.times[1:round(Int, histquantile*end)] - # 47 = the 'base' width such that the histogram doesn't go past the statistics text bins, logbins = bindata(histtimes, histwidth - 1), false append!(bins, [1, floor((1-histquantile) * length(t.times))]) # if median size of (bins with >10% average data/bin) is less than 5% of max bin size, log the bin sizes @@ -438,8 +438,8 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial) maxbin = maximum(bins) delta1 = (histtimes[end] - histtimes[1]) / (histwidth - 1) - medpos = 1 + round(Int, (histtimes[length(histtimes) ÷ 2] - histtimes[1]) / delta1) - avgpos = 1 + round(Int, (mean(histtimes) - histtimes[1]) / delta1) + medpos = 1 + round(Int, (histtimes[length(t.times) ÷ 2] - histtimes[1]) / delta1) + avgpos = 1 + round(Int, (mean(t.times) - histtimes[1]) / delta1) print(io, "\n") for histrow in eachrow(hist)