Skip to content

Commit ce89e45

Browse files
committed
Fix remtrailingzeros and add test
1 parent 491aa42 commit ce89e45

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/trials.jl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -466,13 +466,7 @@ function Base.show(io::IO, ::MIME"text/plain", t::Trial)
466466
end
467467
end
468468

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

478472
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)