tools/memory/partition_allocator/trace_utils.py
def ParseTrace(trace: dict,
               compute_result: Callable[[dict, dict], None]) -> dict[int, dict]:
  """Parses a trace, and returns thread cache stats.

  Args:
    trace: As returned by LoadTrace()
    compute_result: function taking |result_for_pid| (which it modifies
      in-place), and |allocators|. It should add any results we'd like to graph
      into |result_for_pid['data']|, as an |np.array|.

  Returns:
    {pid -> {'name': str, 'labels': str, 'data': np.array}.
    Where the data array contains the data we would like to graph. For example,
    it may contain 'size' and 'fragmentation' columns, which is what
    |PlotProcessFragmentation| expects.
  """
  dumps = _GetAllocatorDumps(trace)
  pid_to_name, pid_to_labels = _ProcessNamesAndLabels(trace)

  result = {}
  for dump in dumps:
    pid = dump['pid']
    allocators = dump['args']['dumps']['allocators']

    # The browser process also has global dumps, we do not care about these.
    # These dumps are also returned from |_GetAllocatorDumps|, but the
    # corresponding metadata for them is not returned from
    # |_ProcessNamesAndLabels|. We have to special-case things _somewhere_ to
    # exclude these dumps, and this seems like the best spot.
    if 'global' in allocators:
      continue

    # We only use the last dump for a given pid, overwritting all previous
    # ones.
    result[pid] = {
        'name': pid_to_name[pid],
        'labels': pid_to_labels.get(pid, '')
    }
    compute_result(result[pid], allocators)

  return result
Parses a trace, and returns thread cache stats.

  Args:
    trace: As returned by LoadTrace()
    compute_result: function taking |result_for_pid| (which it modifies
      in-place), and |allocators|. It should add any results we'd like to graph
      into |result_for_pid['data']|, as an |np.array|.

  Returns:
    {pid -> {'name': str, 'labels': str, 'data': np.array}.
    Where the data array contains the data we would like to graph. For example,
    it may contain 'size' and 'fragmentation' columns, which is what
    |PlotProcessFragmentation| expects.
  
Parses a trace, and returns thread cache stats.
Parses a trace and returns thread cache stats .
def ParseTrace(trace: dict,
               compute_result: Callable[[dict, dict], None]) -> dict[int, dict]:
  dumps = _GetAllocatorDumps(trace)
  pid_to_name, pid_to_labels = _ProcessNamesAndLabels(trace)
  result = {}
  for dump in dumps:
    pid = dump['pid']
    allocators = dump['args']['dumps']['allocators']
    if 'global' in allocators:
      continue
    result[pid] = {
        'name': pid_to_name[pid],
        'labels': pid_to_labels.get(pid, '')
    }
    compute_result(result[pid], allocators)
  return result
def ParseTrace ( trace : dict , compute_result : Callable [ [ dict , dict ] , None ] ) -> dict [ int , dict ] : dumps = _GetAllocatorDumps ( trace ) pid_to_name , pid_to_labels = _ProcessNamesAndLabels ( trace ) result = { } for dump in dumps : pid = dump [ 'pid' ] allocators = dump [ 'args' ] [ 'dumps' ] [ 'allocators' ] if 'global' in allocators : continue result [ pid ] = { 'name' : pid_to_name [ pid ] , 'labels' : pid_to_labels . get ( pid , '' ) } compute_result ( result [ pid ] , allocators ) return result
Parses a trace, and returns thread cache stats.
Parses a trace and returns thread cache stats .
"""Parses a trace, and returns thread cache stats.

  Args:
    trace: As returned by LoadTrace()
    compute_result: function taking |result_for_pid| (which it modifies
      in-place), and |allocators|. It should add any results we'd like to graph
      into |result_for_pid['data']|, as an |np.array|.

  Returns:
    {pid -> {'name': str, 'labels': str, 'data': np.array}.
    Where the data array contains the data we would like to graph. For example,
    it may contain 'size' and 'fragmentation' columns, which is what
    |PlotProcessFragmentation| expects.
  """ # The browser process also has global dumps, we do not care about these. # These dumps are also returned from |_GetAllocatorDumps|, but the # corresponding metadata for them is not returned from # |_ProcessNamesAndLabels|. We have to special-case things _somewhere_ to # exclude these dumps, and this seems like the best spot. # We only use the last dump for a given pid, overwritting all previous # ones.
None
trace
dict
As returned by LoadTrace()
As returned by LoadTrace ()
compute_result
Callable[[dict, dict], None]
function taking |result_for_pid| (which it modifies
in-place), and |allocators|. It should add any results we'd like to graph
into |result_for_pid['data']|, as an |np.array|.
function taking |result_for_pid| ( which it modifies in - place ) and |allocators| . It should add any results we ' d like to graph into |result_for_pid [ ' data ' ] | as an |np . array| .