Skip to content

Commit 8dcac4d

Browse files
authored
Allow loading saved benchmark results from version <= 1.3.2 (#351)
* Allow loading saved files without evals_set parameter * Fix parsing * Fix scoping in test * Fix typo * Fix bug * Fix typo * Format
1 parent 3742326 commit 8dcac4d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/serialization.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ function recover(x::Vector)
5353
if ft <: get(SUPPORTED_TYPES, nameof(ft), Union{})
5454
xsi = recover(fields[fn])
5555
else
56-
xsi = convert(ft, fields[fn])
56+
xsi = if fn == "evals_set" && !haskey(fields, fn)
57+
false
58+
else
59+
convert(ft, fields[fn])
60+
end
5761
end
5862
if T == BenchmarkGroup && xsi isa Dict
5963
for (k, v) in copy(xsi)

test/SerializationTests.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,18 @@ end
9999
@test_throws ArgumentError BenchmarkTools.recover([1])
100100
end
101101

102+
@testset "Backwards Comppatibility with evals_set" begin
103+
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}]]]"
104+
json_io = IOBuffer(json_string)
105+
106+
@test BenchmarkTools.load(json_io) ==
107+
[BenchmarkTools.Parameters(5.0, 10000, 1, false, 0.0, true, false, 0.05, 0.01)]
108+
109+
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}]]]"
110+
json_io = IOBuffer(json_string)
111+
112+
@test BenchmarkTools.load(json_io) ==
113+
[BenchmarkTools.Parameters(5.0, 10000, 1, true, 0.0, true, false, 0.05, 0.01)]
114+
end
115+
102116
end # module

0 commit comments

Comments
 (0)