@@ -118,6 +118,12 @@ struct EventType
118118 event:: UInt64
119119end
120120
121+ Base. copy (event:: EventType ) = EventType (event. category, event. event)
122+
123+ function Base. convert (:: Type{EventType} , d:: Dict{String} )
124+ return EventType (d[" category" ], d[" event" ])
125+ end
126+
121127function all_events ()
122128 evts = EventType[]
123129 for (cat_name, cat_id, events) in EVENT_TYPES
@@ -356,6 +362,18 @@ struct Counter
356362 running:: UInt64
357363end
358364
365+ function Base. copy (counter:: Counter )
366+ return Counter (
367+ copy (counter. event), counter. value, counter. enabled, counter. running
368+ )
369+ end
370+
371+ function Base. convert (:: Type{Counter} , d:: Dict{String} )
372+ return Counter (
373+ convert (EventType, d[" event" ]), d[" value" ], d[" enabled" ], d[" running" ]
374+ )
375+ end
376+
359377struct Counters
360378 counters:: Vector{Counter}
361379end
@@ -734,6 +752,14 @@ struct ThreadStats
734752 groups:: Vector{Vector{Counter}}
735753end
736754
755+ function Base. copy (thread_stats:: ThreadStats )
756+ return ThreadStats (thread_stats. pid, copy (thread_stats. groups))
757+ end
758+
759+ function Base. convert (:: Type{ThreadStats} , d:: Dict{String} )
760+ return ThreadStats (d[" pid" ], d[" groups" ])
761+ end
762+
737763function ThreadStats (b:: PerfBench )
738764 groups = Vector{Counter}[]
739765 for g in b. groups
@@ -775,6 +801,10 @@ struct Stats
775801 threads:: Vector{ThreadStats}
776802end
777803
804+ Base. copy (stats:: Stats ) = Stats (copy (stats. threads))
805+
806+ Base. convert (:: Type{Stats} , d:: Dict{String} ) = Stats (d[" threads" ])
807+
778808Stats (b:: PerfBenchThreaded ) = Stats (map (ThreadStats, b. data))
779809
780810Base. show (io:: IO , stats:: Stats ) = printsummary (io, stats)
0 commit comments