Skip to content

Commit 7eebf01

Browse files
authored
Merge pull request #243 from vyu/master
Fix compatibility with Julia v1.0
2 parents db83e8f + 0134242 commit 7eebf01

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/trials.jl

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -455,23 +455,17 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)
455455
end
456456

457457
print(io, "\n")
458-
for histrow in eachrow(hist)
458+
for r in axes(hist, 1)
459459
print(io, "\n", pad, " ")
460-
for (i, bar) in enumerate(histrow)
460+
for (i, bar) in enumerate(view(hist, r, :))
461461
color = :default
462462
if i == avgpos color = :green end
463463
if i == medpos color = :blue end
464464
printstyled(io, bar; color=color)
465465
end
466466
end
467467

468-
function remtrailingzeros(timestr)
469-
if ! isnothing(match(r"\.0+$", timestr))
470-
replace(timestr, r"\.0+$" => "")
471-
else
472-
replace(timestr, r"(\.\d+?)0+$" => s"\1")
473-
end
474-
end
468+
remtrailingzeros(timestr) = replace(timestr, r"\.?0+ " => " ")
475469
minhisttime, maxhisttime = remtrailingzeros.(prettytime.(round.(histtimes[[1; end]], sigdigits=3)))
476470

477471
print(io, "\n", pad, " ", minhisttime)

test/TrialsTests.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,17 @@ else
233233

234234
end
235235

236+
trial = BenchmarkTools.Trial(BenchmarkTools.Parameters(), [1.0, 1.01], [0.0, 0.0], 0, 0)
237+
@test sprint(show, "text/plain", trial) == """
238+
BenchmarkTools.Trial: 2 samples with 1 evaluation.
239+
Range (min … max): 1.000 ns … 1.010 ns ┊ GC (min … max): 0.00% … 0.00%
240+
Time (median): 1.005 ns ┊ GC (median): 0.00%
241+
Time (mean ± σ): 1.005 ns ± 0.007 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
242+
243+
█ █
244+
█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█ ▁
245+
1 ns Histogram: frequency by time 1.01 ns <
246+
247+
Memory estimate: 0 bytes, allocs estimate: 0."""
248+
236249
end # module

0 commit comments

Comments
 (0)