in utils/json_profiles_merger_lib.py [0:0]
def aggregate_data(input_profiles, only_phases=False):
"""Produces the aggregated data from the JSON profile inputs.
Collects information on cat, name and median duration of the events in the
JSON profiles.
Args:
input_profiles: a list of paths to .profile or .profile.gz files.
only_phases: only output entries from phase markers.
Returns:
The list of objects which contain the info about cat, name and statistics on
the
duration of events.
"""
# A map from event name to an object which accumulates the durations.
accum_dict = dict()
for file_path in input_profiles:
if file_path.endswith('.gz'):
with gzip.GzipFile(file_path, 'r') as gz_input_file:
event_list = json.loads(gz_input_file.read().decode('utf-8'))
else:
with open(file_path, 'r') as input_file:
event_list = json.load(input_file)
# The events in the JSON profiles can be presented directly as a list,
# or as the value of key 'traceEvents'.
if 'traceEvents' in event_list:
event_list = event_list['traceEvents']
_accumulate_event_duration(event_list, accum_dict, only_phases)
return _aggregate_from_accum_dict(accum_dict)