@@ -237,32 +237,31 @@ else
237237
238238end
239239
240+ # Trial with 0 samples
240241t0 = BenchmarkTools. Trial (BenchmarkTools. Parameters (), [], [], 0 , 0 )
241242@test sprint (show, " text/plain" , t0) == " Trial: 0 samples"
242243
244+ # Trial with 1 sample
243245t001 = BenchmarkTools. Trial (BenchmarkTools. Parameters (), [pi * 10 ^ 6 ], [0 ], 0 , 0 )
244246s001 = sprint (show, " text/plain" , t001)
245247@test contains (s001, " ┌ Trial:" ) # box starting at the type
246248@test contains (s001, " │ time 3.142 ms" )
247249@test contains (s001, " │ 0 allocations\n " ) # doesn't print 0 bytes after this
248250@test contains (s001, " └ 1 sample, with 1 evaluation" )
249251
252+ # Histogram utils
250253@test BenchmarkTools. asciihist ([1 ,2 ,3 ]) == [' ▃' ' ▆' ' █' ]
251254@test BenchmarkTools. asciihist ([1 ,2 ,0 ,3 ], 2 ) == [' ' ' ▃' ' ' ' █' ; ' ▇' ' █' ' ▁' ' █' ]
252255
253256@test BenchmarkTools. histogram_bindata ([1.1 , 3.1 , 99 ], 1 : 3 ) == [1 ,0 ,2 ]
254257@test BenchmarkTools. histogram_bindata ([1.1 , - 99 , 3.1 ], 1 : 3.0 ) == [1 ,0 ,1 ]
255258
259+ # Trials with several samples
256260t003 = BenchmarkTools. Trial (BenchmarkTools. Parameters (), [0.01 , 0.02 , 0.04 ], [0 ,0 ,0 ], 0 , 0 )
257261s003 = sprint (show, " text/plain" , t003)
258262@test contains (s003, " 1 ns +" ) # right limit is 1ns
259263@test contains (s003, " min 0.010 ns, median 0.020 ns, mean 0.023 ns, 99ᵗʰ 0.040 ns" )
260264
261- @test sprint (show, t001) == " Trial(3.142 ms)"
262- @test sprint (show, t003) == " Trial(0.010 ns)"
263- @test sprint (show, " text/plain" , [t001, t003]) == " 2-element Vector{BenchmarkTools.Trial}:\n 3.142 ms\n 0.010 ns"
264- @test_skip sprint (show, " text/plain" , [t0]) == " 1-element Vector{BenchmarkTools.Trial}:\n ??"
265-
266265t123 = BenchmarkTools. Trial (BenchmarkTools. Parameters (), [1 ,2 ,3. ], [0 ,0 ,0. ], 0 , 0 )
267266s123 = sprint (show, " text/plain" , t123)
268267@test contains (s123, " min 1.000 ns, median 2.000 ns, mean 2.000 ns" )
@@ -282,6 +281,12 @@ s456 = sprint(show, "text/plain", t456)
282281@test contains (s456, " │ █▁▁▁▁▁▁▁" )
283282@test contains (s456, " └ 100 ns " ) # box closing + left endpoint without decimals
284283
284+ # Compact show & arrays of Trials
285+ @test sprint (show, t001) == " Trial(3.142 ms)"
286+ @test sprint (show, t003) == " Trial(0.010 ns)"
287+ @test sprint (show, " text/plain" , [t001, t003]) == " 2-element Vector{BenchmarkTools.Trial}:\n 3.142 ms\n 0.010 ns"
288+ @test_skip sprint (show, " text/plain" , [t0]) == " 1-element Vector{BenchmarkTools.Trial}:\n ??"
289+
285290#=
286291
287292# Some visual histogram checks, in which mean/median should highlight a bar, or not:
0 commit comments