Skip to content

Commit 8ef06d7

Browse files
committed
Add linux perf parameters to tests
1 parent e5dd040 commit 8ef06d7

File tree

2 files changed

+90
-21
lines changed

2 files changed

+90
-21
lines changed

test/ParametersTests.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ p = Parameters(;
2626
gcsample=false,
2727
time_tolerance=0.043,
2828
memory_tolerance=0.15,
29+
enable_linux_perf=false,
30+
linux_perf_groups="(branch-instructions)",
31+
linux_perf_spaces=(true, true, false),
32+
linux_perf_threads=false,
33+
linux_perf_gcscrub=false,
2934
)
3035
oldseconds = BenchmarkTools.DEFAULT_PARAMETERS.seconds
3136
oldgctrial = BenchmarkTools.DEFAULT_PARAMETERS.gctrial
@@ -35,6 +40,11 @@ oldsamples = BenchmarkTools.DEFAULT_PARAMETERS.samples
3540
oldevals = BenchmarkTools.DEFAULT_PARAMETERS.evals
3641
oldoverhead = BenchmarkTools.DEFAULT_PARAMETERS.overhead
3742
oldgcsample = BenchmarkTools.DEFAULT_PARAMETERS.gcsample
43+
old_enable_linux_perf = BenchmarkTools.DEFAULT_PARAMETERS.enable_linux_perf
44+
old_linux_perf_groups = BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_groups
45+
old_linux_perf_spaces = BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_spaces
46+
old_linux_perf_threads = BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_threads
47+
old_enable_linux_gcsample = BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_gcscrub
3848
BenchmarkTools.DEFAULT_PARAMETERS.seconds = p.seconds
3949
BenchmarkTools.DEFAULT_PARAMETERS.gctrial = p.gctrial
4050
BenchmarkTools.DEFAULT_PARAMETERS.time_tolerance = p.time_tolerance
@@ -43,6 +53,11 @@ BenchmarkTools.DEFAULT_PARAMETERS.samples = p.samples
4353
BenchmarkTools.DEFAULT_PARAMETERS.evals = p.evals
4454
BenchmarkTools.DEFAULT_PARAMETERS.overhead = p.overhead
4555
BenchmarkTools.DEFAULT_PARAMETERS.gcsample = p.gcsample
56+
BenchmarkTools.DEFAULT_PARAMETERS.enable_linux_perf = p.enable_linux_perf
57+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_groups = p.linux_perf_groups
58+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_spaces = p.linux_perf_spaces
59+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_threads = p.linux_perf_threads
60+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_gcscrub = p.linux_perf_gcscrub
4661
@test p == Parameters()
4762
@test p == Parameters(p)
4863
BenchmarkTools.DEFAULT_PARAMETERS.seconds = oldseconds
@@ -53,5 +68,10 @@ BenchmarkTools.DEFAULT_PARAMETERS.samples = oldsamples
5368
BenchmarkTools.DEFAULT_PARAMETERS.evals = oldevals
5469
BenchmarkTools.DEFAULT_PARAMETERS.overhead = oldoverhead
5570
BenchmarkTools.DEFAULT_PARAMETERS.gcsample = oldgcsample
71+
BenchmarkTools.DEFAULT_PARAMETERS.enable_linux_perf = old_enable_linux_perf
72+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_groups = old_linux_perf_groups
73+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_spaces = old_linux_perf_spaces
74+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_threads = old_linux_perf_threads
75+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_gcscrub = old_enable_linux_gcsample
5676

5777
end # module

test/SerializationTests.jl

Lines changed: 70 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,23 @@ function withtempdir(f::Function)
1919
end
2020

2121
@testset "Successful (de)serialization" begin
22-
b = @benchmarkable sin(1)
23-
tune!(b)
24-
bb = run(b)
25-
26-
withtempdir() do
27-
tmp = joinpath(pwd(), "tmp.json")
28-
29-
BenchmarkTools.save(tmp, b.params, bb)
30-
@test isfile(tmp)
31-
32-
results = BenchmarkTools.load(tmp)
33-
@test results isa Vector{Any}
34-
@test length(results) == 2
35-
@test eq(results[1], b.params)
36-
@test eq(results[2], bb)
22+
for enable_linux_perf in (false, true)
23+
b = @benchmarkable sin(1) enable_linux_perf = enable_linux_perf
24+
tune!(b)
25+
bb = run(b)
26+
27+
withtempdir() do
28+
tmp = joinpath(pwd(), "tmp.json")
29+
30+
BenchmarkTools.save(tmp, b.params, bb)
31+
@test isfile(tmp)
32+
33+
results = BenchmarkTools.load(tmp)
34+
@test results isa Vector{Any}
35+
@test length(results) == 2
36+
@test eq(results[1], b.params)
37+
@test eq(results[2], bb)
38+
end
3739
end
3840

3941
# Nested BenchmarkGroups
@@ -99,22 +101,69 @@ end
99101
@test_throws ArgumentError BenchmarkTools.recover([1])
100102
end
101103

102-
@testset "Backwards Comppatibility with evals_set" begin
104+
@testset "Backwards Compatibility with evals_set and linux perf options" begin
103105
json_string = "[{\"Julia\":\"1.11.0-DEV.1116\",\"BenchmarkTools\":\"1.4.0\"},[[\"Parameters\",{\"gctrial\":true,\"time_tolerance\":0.05,\"samples\":10000,\"evals\":1,\"gcsample\":false,\"seconds\":5.0,\"overhead\":0.0,\"memory_tolerance\":0.01}]]]"
104106
json_io = IOBuffer(json_string)
105107

106-
@test BenchmarkTools.load(json_io) ==
107-
[BenchmarkTools.Parameters(5.0, 10000, 1, false, 0.0, true, false, 0.05, 0.01)]
108+
@test BenchmarkTools.load(json_io) == [
109+
BenchmarkTools.Parameters(
110+
5.0,
111+
10000,
112+
1,
113+
false,
114+
0.0,
115+
true,
116+
false,
117+
0.05,
118+
0.01,
119+
false,
120+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_groups,
121+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_spaces,
122+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_threads,
123+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_gcscrub,
124+
),
125+
]
108126

109127
json_string = "[{\"Julia\":\"1.11.0-DEV.1116\",\"BenchmarkTools\":\"1.4.0\"},[[\"Parameters\",{\"gctrial\":true,\"time_tolerance\":0.05,\"evals_set\":true,\"samples\":10000,\"evals\":1,\"gcsample\":false,\"seconds\":5.0,\"overhead\":0.0,\"memory_tolerance\":0.01}]]]"
110128
json_io = IOBuffer(json_string)
111129

112-
@test BenchmarkTools.load(json_io) ==
113-
[BenchmarkTools.Parameters(5.0, 10000, 1, true, 0.0, true, false, 0.05, 0.01)]
130+
@test BenchmarkTools.load(json_io) == [
131+
BenchmarkTools.Parameters(
132+
5.0,
133+
10000,
134+
1,
135+
true,
136+
0.0,
137+
true,
138+
false,
139+
0.05,
140+
0.01,
141+
false,
142+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_groups,
143+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_spaces,
144+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_threads,
145+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_gcscrub,
146+
),
147+
]
114148
end
115149

116150
@testset "Inf in Paramters struct" begin
117-
params = BenchmarkTools.Parameters(Inf, 10000, 1, false, Inf, true, false, Inf, Inf)
151+
params = BenchmarkTools.Parameters(
152+
Inf,
153+
10000,
154+
1,
155+
false,
156+
Inf,
157+
true,
158+
false,
159+
Inf,
160+
Inf,
161+
false,
162+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_groups,
163+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_spaces,
164+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_threads,
165+
BenchmarkTools.DEFAULT_PARAMETERS.linux_perf_gcscrub,
166+
)
118167

119168
io = IOBuffer()
120169
BenchmarkTools.save(io, params)

0 commit comments

Comments
 (0)