tools/perf/cli_tools/pinpoint_traces.py
def LoadJsonFile(json_file, compiled_re):
  """From the JSON file takes only the events that match.

  Note: This function loads a typical JSON file very slowly, for several
  seconds. Most time is spent in the Python json module.

  Args:
    json_file: (str) Path to the JSON file to load
    compiled_re: A compiled regular expression that selects event by |name| if
        the latter matches.

  Returns:
    A dict with this internal structure:
        { tid: { (int) ts: [event, ...] } },
    where:
      tid: (int) Thread ID of all the events it maps to.
      ts: (int) Trace timestamp (in microseconds) of the beginning of the event.
      event: (LeanEvent) One extracted event only containing the fields for
          writing to the CSV file, pairing 'begin' and 'end' events into a
          single one.

  """
  with open(json_file) as f:
    events = json.load(f)
  tids = {}
  tid_to_pid = {}
  for event in events['traceEvents']:
    assert 'ph' in event
    assert 'ts' in event
    phase = event['ph']
    if not phase in SUPPORTED_PHASES:
      continue
    assert 'tid' in event
    assert 'pid' in event
    tid = event['tid']
    pid = event['pid']
    old_pid = tid_to_pid.setdefault(tid, pid)
    assert pid == old_pid, 'Two TIDs match one PID'
    event_name = event['name']
    if compiled_re.match(event_name):
      ts_to_events = tids.setdefault(tid, {})
      ts = event['ts']
      event_list = ts_to_events.setdefault(ts, [])
      event_list.append(LeanEvent(event))
  return tids
From the JSON file takes only the events that match.

  Note: This function loads a typical JSON file very slowly, for several
  seconds. Most time is spent in the Python json module.

  Args:
    json_file: (str) Path to the JSON file to load
    compiled_re: A compiled regular expression that selects event by |name| if
        the latter matches.

  Returns:
    A dict with this internal structure:
        { tid: { (int) ts: [event, ...] } },
    where:
      tid: (int) Thread ID of all the events it maps to.
      ts: (int) Trace timestamp (in microseconds) of the beginning of the event.
      event: (LeanEvent) One extracted event only containing the fields for
          writing to the CSV file, pairing 'begin' and 'end' events into a
          single one.

  
From the JSON file takes only the events that match.
Note: This function loads a typical JSON file very slowly, for several
seconds. Most time is spent in the Python json module.
From the JSON file takes only the events that match . Note : This function loads a typical JSON file very slowly for several seconds . Most time is spent in the Python json module .
def LoadJsonFile(json_file, compiled_re):
  with open(json_file) as f:
    events = json.load(f)
  tids = {}
  tid_to_pid = {}
  for event in events['traceEvents']:
    assert 'ph' in event
    assert 'ts' in event
    phase = event['ph']
    if not phase in SUPPORTED_PHASES:
      continue
    assert 'tid' in event
    assert 'pid' in event
    tid = event['tid']
    pid = event['pid']
    old_pid = tid_to_pid.setdefault(tid, pid)
    assert pid == old_pid, 'Two TIDs match one PID'
    event_name = event['name']
    if compiled_re.match(event_name):
      ts_to_events = tids.setdefault(tid, {})
      ts = event['ts']
      event_list = ts_to_events.setdefault(ts, [])
      event_list.append(LeanEvent(event))
  return tids
def LoadJsonFile ( json_file , compiled_re ) : with open ( json_file ) as f : events = json . load ( f ) tids = { } tid_to_pid = { } for event in events [ 'traceEvents' ] : assert 'ph' in event assert 'ts' in event phase = event [ 'ph' ] if not phase in SUPPORTED_PHASES : continue assert 'tid' in event assert 'pid' in event tid = event [ 'tid' ] pid = event [ 'pid' ] old_pid = tid_to_pid . setdefault ( tid , pid ) assert pid == old_pid , 'Two TIDs match one PID' event_name = event [ 'name' ] if compiled_re . match ( event_name ) : ts_to_events = tids . setdefault ( tid , { } ) ts = event [ 'ts' ] event_list = ts_to_events . setdefault ( ts , [ ] ) event_list . append ( LeanEvent ( event ) ) return tids
From the JSON file takes only the events that match.
From the JSON file takes only the events that match .
"""From the JSON file takes only the events that match.

  Note: This function loads a typical JSON file very slowly, for several
  seconds. Most time is spent in the Python json module.

  Args:
    json_file: (str) Path to the JSON file to load
    compiled_re: A compiled regular expression that selects event by |name| if
        the latter matches.

  Returns:
    A dict with this internal structure:
        { tid: { (int) ts: [event, ...] } },
    where:
      tid: (int) Thread ID of all the events it maps to.
      ts: (int) Trace timestamp (in microseconds) of the beginning of the event.
      event: (LeanEvent) One extracted event only containing the fields for
          writing to the CSV file, pairing 'begin' and 'end' events into a
          single one.

  """
A dict with this internal structure:
{ tid: { (int) ts: [event, ...] } },
where:
tid: (int) Thread ID of all the events it maps to.
ts: (int) Trace timestamp (in microseconds) of the beginning of the event.
event: (LeanEvent) One extracted event only containing the fields for
writing to the CSV file, pairing 'begin' and 'end' events into a
single one.
A dict with this internal structure : { tid : { ( int ) ts : [ event ... ] } } where : tid : ( int ) Thread ID of all the events it maps to . ts : ( int ) Trace timestamp ( in microseconds ) of the beginning of the event . event : ( LeanEvent ) One extracted event only containing the fields for writing to the CSV file pairing ' begin ' and ' end ' events into a single one .
json_file
(str) Path to the JSON file to load
( str ) Path to the JSON file to load
compiled_re
A compiled regular expression that selects event by |name| if
the latter matches.
A compiled regular expression that selects event by |name| if the latter matches .