Skip to content

Commit

Permalink
Merge pull request #250 from giordano/mg/sort-times
Browse files Browse the repository at this point in the history
Make sure times are sorted in the `at-benchmark` histogram
  • Loading branch information
vchuravy authored Aug 25, 2021
2 parents 540fa91 + e4a02bc commit d34a767
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "BenchmarkTools"
uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
version = "1.1.3"
version = "1.1.4"

[deps]
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
Expand Down
20 changes: 12 additions & 8 deletions src/trials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)
print(io, "BenchmarkTools.Trial: ", length(t), " sample", if length(t) > 1 "s" else "" end,
" with ", t.params.evals, " evaluation", if t.params.evals > 1 "s" else "" end ,".\n")

perm = sortperm(t.times)
times = t.times[perm]
gctimes = t.gctimes[perm]

if length(t) > 1
med = median(t)
avg = mean(t)
Expand All @@ -353,16 +357,16 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)

medtime, medgc = prettytime(time(med)), prettypercent(gcratio(med))
avgtime, avggc = prettytime(time(avg)), prettypercent(gcratio(avg))
stdtime, stdgc = prettytime(time(std)), prettypercent(Statistics.std(t.gctimes ./ t.times))
stdtime, stdgc = prettytime(time(std)), prettypercent(Statistics.std(gctimes ./ times))
mintime, mingc = prettytime(time(min)), prettypercent(gcratio(min))
maxtime, maxgc = prettytime(time(max)), prettypercent(gcratio(max))

memorystr = string(prettymemory(memory(min)))
allocsstr = string(allocs(min))
elseif length(t) == 1
print(io, pad, " Single result which took ")
printstyled(io, prettytime(t.times[1]); color=:blue)
print(io, " (", prettypercent(t.gctimes[1]/t.times[1]), " GC) ")
printstyled(io, prettytime(times[1]); color=:blue)
print(io, " (", prettypercent(gctimes[1]/times[1]), " GC) ")
print(io, "to evaluate,\n")
print(io, pad, " with a memory estimate of ")
printstyled(io, prettymemory(t.memory[1]); color=:yellow)
Expand Down Expand Up @@ -435,11 +439,11 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)
histheight = 2
histwidth = 42 + lmaxtimewidth + rmaxtimewidth

histtimes = t.times[1:round(Int, histquantile*end)]
histtimes = times[1:round(Int, histquantile*end)]
bins, logbins = bindata(histtimes, histwidth - 1), false
append!(bins, [1, floor((1-histquantile) * length(t.times))])
append!(bins, [1, floor((1-histquantile) * length(times))])
# if median size of (bins with >10% average data/bin) is less than 5% of max bin size, log the bin sizes
if median(filter(b -> b > 0.1 * length(t.times) / histwidth, bins)) / maximum(bins) < 0.05
if median(filter(b -> b > 0.1 * length(times) / histwidth, bins)) / maximum(bins) < 0.05
bins, logbins = log.(1 .+ bins), true
end
hist = asciihist(bins, histheight)
Expand All @@ -448,8 +452,8 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)

delta1 = (histtimes[end] - histtimes[1]) / (histwidth - 1)
if delta1 > 0
medpos = 1 + round(Int, (histtimes[length(t.times) ÷ 2] - histtimes[1]) / delta1)
avgpos = 1 + round(Int, (mean(t.times) - histtimes[1]) / delta1)
medpos = 1 + round(Int, (histtimes[length(times) ÷ 2] - histtimes[1]) / delta1)
avgpos = 1 + round(Int, (mean(times) - histtimes[1]) / delta1)
else
medpos, avgpos = 1, 1
end
Expand Down

2 comments on commit d34a767

@vchuravy
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/43503

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.4 -m "<description of version>" d34a767500ef983a3c1166b7facffde10a6cf998
git push origin v1.1.4

Please sign in to comment.