Skip to content

Commit 3629562

Browse files
committed
Update uses of Trial constructor and readd whitespace to test
1 parent 23ec77d commit 3629562

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

src/trials.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ function Base.:(==)(a::Trial, b::Trial)
3434
end
3535

3636
function Base.copy(t::Trial)
37-
return Trial(copy(t.params), copy(t.times), copy(t.gctimes), t.memory, t.allocs)
37+
return Trial(
38+
copy(t.params),
39+
copy(t.times),
40+
copy(t.gctimes),
41+
t.memory,
42+
t.allocs,
43+
nothing, # There is no copy method for LinuxPerf.Stats or LinuxPerf.ThreadStats
44+
)
3845
end
3946

4047
function Base.push!(t::Trial, trial_contents::TrialContents)
@@ -65,7 +72,9 @@ function Base.getindex(t::Trial, i::Number)
6572
),
6673
)
6774
end
68-
Base.getindex(t::Trial, i) = Trial(t.params, t.times[i], t.gctimes[i], t.memory, t.allocs)
75+
function Base.getindex(t::Trial, i)
76+
return Trial(t.params, t.times[i], t.gctimes[i], t.memory, t.allocs, nothing)
77+
end
6978
Base.lastindex(t::Trial) = length(t)
7079

7180
function Base.sort!(t::Trial)

test/ExecutionTests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ for (tf, rex1, rex2) in (
235235
ioctx = IOContext(io, :logbins => tf)
236236
# A flat distribution won't trigger log by default
237237
b = BenchmarkTools.Trial(
238-
BenchmarkTools.DEFAULT_PARAMETERS, 0.001 * (1:100) * 1e9, zeros(100), 0, 0
238+
BenchmarkTools.DEFAULT_PARAMETERS, 0.001 * (1:100) * 1e9, zeros(100), 0, 0, nothing
239239
)
240240
show(ioctx, MIME("text/plain"), b)
241241
str = String(take!(io))
@@ -249,6 +249,7 @@ for (tf, rex1, rex2) in (
249249
zeros(100),
250250
0,
251251
0,
252+
nothing,
252253
)
253254
show(ioctx, MIME("text/plain"), b)
254255
str = String(take!(io))

test/GroupsTests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ g2["a"] = t2a
3939
g2["b"] = t2b
4040
g2["c"] = tc
4141

42-
trial = BenchmarkTools.Trial(Parameters(), [1, 2, 5], [0, 1, 1], 3, 56)
42+
trial = BenchmarkTools.Trial(Parameters(), [1, 2, 5], [0, 1, 1], 3, 56, nothing)
4343

4444
gtrial = BenchmarkGroup([], Dict("t" => trial))
4545

test/TrialsTests.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module TrialsTests
22

33
using BenchmarkTools
4+
using BenchmarkTools: TrialContents
45
using Test
56

67
#########
@@ -46,7 +47,7 @@ trial2.params = trial1.params
4647

4748
# outlier trimming
4849
trial3 = BenchmarkTools.Trial(
49-
BenchmarkTools.Parameters(), [1, 2, 3, 10, 11], [1, 1, 1, 1, 1], 1, 1
50+
BenchmarkTools.Parameters(), [1, 2, 3, 10, 11], [1, 1, 1, 1, 1], 1, 1, nothing
5051
)
5152

5253
trimtrial3 = rmskew(trial3)
@@ -62,11 +63,11 @@ rmskew!(trial3)
6263
randtrial = BenchmarkTools.Trial(BenchmarkTools.Parameters())
6364

6465
for _ in 1:40
65-
push!(randtrial, TrialContents(rand(1:20), 1, 1, 1))
66+
push!(randtrial, TrialContents(rand(1:20), 1, 1, 1, nothing, nothing, nothing))
6667
end
6768

6869
while mean(randtrial) <= median(randtrial)
69-
push!(randtrial, TrialContents(rand(10:20), 1, 1, 1))
70+
push!(randtrial, TrialContents(rand(10:20), 1, 1, 1, nothing, nothing, nothing))
7071
end
7172

7273
rmskew!(randtrial)
@@ -231,7 +232,7 @@ tj_r_2 = judge(tr; time_tolerance=2.0, memory_tolerance=2.0)
231232
@test BenchmarkTools.prettymemory(1073741824) == "1.00 GiB"
232233

233234
@test sprint(show, "text/plain", ta) == sprint(show, ta; context=:compact => false) == """
234-
BenchmarkTools.TrialEstimate:
235+
BenchmarkTools.TrialEstimate:
235236
time: 0.490 ns
236237
gctime: 0.000 ns (0.00%)
237238
memory: 2 bytes
@@ -246,7 +247,7 @@ BenchmarkTools.TrialEstimate:
246247

247248
@test sprint(show, [ta, tb]) == "BenchmarkTools.TrialEstimate[0.490 ns, 1.000 ns]"
248249

249-
trial1sample = BenchmarkTools.Trial(BenchmarkTools.Parameters(), [1], [1], 1, 1)
250+
trial1sample = BenchmarkTools.Trial(BenchmarkTools.Parameters(), [1], [1], 1, 1, nothing)
250251
@test try
251252
display(trial1sample)
252253
true
@@ -267,14 +268,16 @@ else
267268
1.000 ns"""
268269
end
269270

270-
trial = BenchmarkTools.Trial(BenchmarkTools.Parameters(), [1.0, 1.01], [0.0, 0.0], 0, 0)
271+
trial = BenchmarkTools.Trial(
272+
BenchmarkTools.Parameters(), [1.0, 1.01], [0.0, 0.0], 0, 0, nothing
273+
)
271274
@test sprint(show, "text/plain", trial) == """
272275
BenchmarkTools.Trial: 2 samples with 1 evaluation.
273276
Range (min … max): 1.000 ns … 1.010 ns ┊ GC (min … max): 0.00% … 0.00%
274277
Time (median): 1.005 ns ┊ GC (median): 0.00%
275278
Time (mean ± σ): 1.005 ns ± 0.007 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
276279
277-
█ █
280+
█ █
278281
█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█ ▁
279282
1 ns Histogram: frequency by time 1.01 ns <
280283

0 commit comments

Comments
 (0)