@@ -237,32 +237,31 @@ else
237
237
238
238
end
239
239
240
+ # Trial with 0 samples
240
241
t0 = BenchmarkTools. Trial (BenchmarkTools. Parameters (), [], [], 0 , 0 )
241
242
@test sprint (show, " text/plain" , t0) == " Trial: 0 samples"
242
243
244
+ # Trial with 1 sample
243
245
t001 = BenchmarkTools. Trial (BenchmarkTools. Parameters (), [pi * 10 ^ 6 ], [0 ], 0 , 0 )
244
246
s001 = sprint (show, " text/plain" , t001)
245
247
@test contains (s001, " ┌ Trial:" ) # box starting at the type
246
248
@test contains (s001, " │ time 3.142 ms" )
247
249
@test contains (s001, " │ 0 allocations\n " ) # doesn't print 0 bytes after this
248
250
@test contains (s001, " └ 1 sample, with 1 evaluation" )
249
251
252
+ # Histogram utils
250
253
@test BenchmarkTools. asciihist ([1 ,2 ,3 ]) == [' ▃' ' ▆' ' █' ]
251
254
@test BenchmarkTools. asciihist ([1 ,2 ,0 ,3 ], 2 ) == [' ' ' ▃' ' ' ' █' ; ' ▇' ' █' ' ▁' ' █' ]
252
255
253
256
@test BenchmarkTools. histogram_bindata ([1.1 , 3.1 , 99 ], 1 : 3 ) == [1 ,0 ,2 ]
254
257
@test BenchmarkTools. histogram_bindata ([1.1 , - 99 , 3.1 ], 1 : 3.0 ) == [1 ,0 ,1 ]
255
258
259
+ # Trials with several samples
256
260
t003 = BenchmarkTools. Trial (BenchmarkTools. Parameters (), [0.01 , 0.02 , 0.04 ], [0 ,0 ,0 ], 0 , 0 )
257
261
s003 = sprint (show, " text/plain" , t003)
258
262
@test contains (s003, " 1 ns +" ) # right limit is 1ns
259
263
@test contains (s003, " min 0.010 ns, median 0.020 ns, mean 0.023 ns, 99ᵗʰ 0.040 ns" )
260
264
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
-
266
265
t123 = BenchmarkTools. Trial (BenchmarkTools. Parameters (), [1 ,2 ,3. ], [0 ,0 ,0. ], 0 , 0 )
267
266
s123 = sprint (show, " text/plain" , t123)
268
267
@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)
282
281
@test contains (s456, " │ █▁▁▁▁▁▁▁" )
283
282
@test contains (s456, " └ 100 ns " ) # box closing + left endpoint without decimals
284
283
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
+
285
290
#=
286
291
287
292
# Some visual histogram checks, in which mean/median should highlight a bar, or not:
0 commit comments