1
1
const VERSIONS = Dict (
2
- " Julia" => string (VERSION ), " BenchmarkTools" => string (BENCHMARKTOOLS_VERSION)
2
+ " Julia" => string (VERSION ),
3
+ " BenchmarkTools" => string (BENCHMARKTOOLS_VERSION),
4
+ " LinuxPerf" => string (LINUXPERF_VERSION),
3
5
)
4
6
5
7
# TODO : Add any new types as they're added
@@ -29,6 +31,24 @@ function JSON.lower(x::Union{values(SUPPORTED_TYPES)...})
29
31
return [string (nameof (typeof (x))), d]
30
32
end
31
33
34
+ # Should this be in LinuxPerf?
35
+ JSON. lower (:: typeof (LinuxPerf. parse_groups)) = " LinuxPerf.parse_groups"
36
+
37
+ # Should this be in LinuxPerf?
38
+ # Need this to deserialize LinuxPerf.Stats
39
+ Base. convert (:: Type{LinuxPerf.Stats} , d:: Dict{String} ) = LinuxPerf. Stats (d[" threads" ])
40
+ function Base. convert (:: Type{LinuxPerf.ThreadStats} , d:: Dict{String} )
41
+ return LinuxPerf. ThreadStats (d[" pid" ], d[" groups" ])
42
+ end
43
+ function Base. convert (:: Type{LinuxPerf.EventType} , d:: Dict{String} )
44
+ return LinuxPerf. EventType (d[" category" ], d[" event" ])
45
+ end
46
+ function Base. convert (:: Type{LinuxPerf.Counter} , d:: Dict{String} )
47
+ return LinuxPerf. Counter (
48
+ convert (LinuxPerf. EventType, d[" event" ]), d[" running" ], d[" enabled" ], d[" value" ]
49
+ )
50
+ end
51
+
32
52
# a minimal 'eval' function, mirroring KeyTypes, but being slightly more lenient
33
53
safeeval (@nospecialize x) = x
34
54
safeeval (x:: QuoteNode ) = x. value
@@ -50,8 +70,27 @@ function recover(x::Vector)
50
70
for i in 1 : fc
51
71
ft = fieldtype (T, i)
52
72
fn = String (fieldname (T, i))
53
- if ft <: get (SUPPORTED_TYPES, nameof (ft), Union{})
73
+ if ft == Union{Nothing,LinuxPerf. Stats}
74
+ xsi = if isnothing (fields[fn])
75
+ nothing
76
+ else
77
+ convert (ft, fields[fn])
78
+ end
79
+ elseif ft <: get (SUPPORTED_TYPES, nameof (ft), Union{})
54
80
xsi = recover (fields[fn])
81
+ elseif fn == " linux_perf_options"
82
+ field_val = fields[fn]
83
+ xsi = (
84
+ events= Expr (
85
+ Symbol (field_val[" events" ][" head" ]),
86
+ LinuxPerf. parse_groups,
87
+ field_val[" events" ][" args" ][2 ],
88
+ ),
89
+ spaces= Expr (
90
+ Symbol (field_val[" spaces" ][" head" ]), field_val[" spaces" ][" args" ]. ..
91
+ ),
92
+ threads= field_val[" threads" ],
93
+ )
55
94
else
56
95
xsi = convert (ft, fields[fn])
57
96
end
0 commit comments