Skip to content

Commit aafc7e1

Browse files
authored
Recursively deserialize nested BenchmarkGroups (#85)
1 parent 9e91a17 commit aafc7e1

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/serialization.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ function recover(x::Vector)
3333
else
3434
convert(ft, fields[fn])
3535
end
36+
if T == BenchmarkGroup && xs[i] isa Dict
37+
for (k, v) in xs[i]
38+
if v isa Vector && length(v) == 2 && v[1] isa String
39+
xs[i][k] = recover(v)
40+
end
41+
end
42+
end
3643
end
3744
T(xs...)
3845
end

test/SerializationTests.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ end
3535
@test eq(results[1], b)
3636
@test eq(results[2], bb)
3737
end
38+
39+
# Nested BenchmarkGroups
40+
withtempdir() do
41+
tmp = joinpath(pwd(), "tmp.json")
42+
43+
g = BenchmarkGroup()
44+
g["a"] = BenchmarkGroup()
45+
g["b"] = BenchmarkGroup()
46+
g["c"] = BenchmarkGroup()
47+
BenchmarkTools.save(tmp, g)
48+
49+
results = BenchmarkTools.load(tmp)[1]
50+
@test results isa BenchmarkGroup
51+
@test all(v->v isa BenchmarkGroup, values(results.data))
52+
end
3853
end
3954

4055
@testset "Deprecated behaviors" begin

0 commit comments

Comments
 (0)