tools/android/native_lib_memory/process_residency.py
def PlotResidency(data, output_filename):
  """Creates a graph of residency.

  Args:
    data: (dict) As returned by ParseDump().
    output_filename: (str) Output filename.
  """
  residency = data['residency']
  max_percentage = max((100. * sum(d)) / len(d) for d in residency.values())
  logging.info('Max residency = %.2f%%', max_percentage)

  start = data['start']
  end = data['end']
  _, ax = plt.subplots(figsize=(20, 10))
  timestamps = sorted(residency.keys())
  x_max = len(list(residency.values())[0]) * 4096
  for t in timestamps:
    offset_ms = (t - timestamps[0]) / 1e6
    incore = [i * 4096 for (i, x) in enumerate(residency[t]) if x]
    outcore = [i * 4096 for (i, x) in enumerate(residency[t]) if not x]
    percentage = 100. * len(incore) / (len(incore) + len(outcore))
    plt.text(x_max, offset_ms, '%.1f%%' % percentage)
    for (d, color) in ((incore, (.2, .6, .05, 1)), (outcore, (1, 0, 0, 1))):
      segments = [[(x, offset_ms), (x + 4096, offset_ms)] for x in d]
      colors = np.array([color] * len(segments))
      lc = mc.LineCollection(segments, colors=colors, linewidths=8)
      ax.add_collection(lc)

  plt.axvline(start)
  plt.axvline(end)
  plt.title('Code residency vs time since startup.')
  plt.xlabel('Code page offset (bytes)')
  plt.ylabel('Time since startup (ms)')
  plt.ylim(0, ymax=(timestamps[-1] - timestamps[0]) / 1e6)
  plt.xlim(xmin=0, xmax=x_max)
  plt.savefig(output_filename, bbox_inches='tight', dpi=300)
Creates a graph of residency.

  Args:
    data: (dict) As returned by ParseDump().
    output_filename: (str) Output filename.
  
Creates a graph of residency.
Creates a graph of residency .
def PlotResidency(data, output_filename):
  residency = data['residency']
  max_percentage = max((100. * sum(d)) / len(d) for d in residency.values())
  logging.info('Max residency = %.2f%%', max_percentage)
  start = data['start']
  end = data['end']
  _, ax = plt.subplots(figsize=(20, 10))
  timestamps = sorted(residency.keys())
  x_max = len(list(residency.values())[0]) * 4096
  for t in timestamps:
    offset_ms = (t - timestamps[0]) / 1e6
    incore = [i * 4096 for (i, x) in enumerate(residency[t]) if x]
    outcore = [i * 4096 for (i, x) in enumerate(residency[t]) if not x]
    percentage = 100. * len(incore) / (len(incore) + len(outcore))
    plt.text(x_max, offset_ms, '%.1f%%' % percentage)
    for (d, color) in ((incore, (.2, .6, .05, 1)), (outcore, (1, 0, 0, 1))):
      segments = [[(x, offset_ms), (x + 4096, offset_ms)] for x in d]
      colors = np.array([color] * len(segments))
      lc = mc.LineCollection(segments, colors=colors, linewidths=8)
      ax.add_collection(lc)
  plt.axvline(start)
  plt.axvline(end)
  plt.title('Code residency vs time since startup.')
  plt.xlabel('Code page offset (bytes)')
  plt.ylabel('Time since startup (ms)')
  plt.ylim(0, ymax=(timestamps[-1] - timestamps[0]) / 1e6)
  plt.xlim(xmin=0, xmax=x_max)
  plt.savefig(output_filename, bbox_inches='tight', dpi=300)
def PlotResidency ( data , output_filename ) : residency = data [ 'residency' ] max_percentage = max ( ( 100. * sum ( d ) ) / len ( d ) for d in residency . values ( ) ) logging . info ( 'Max residency = %.2f%%' , max_percentage ) start = data [ 'start' ] end = data [ 'end' ] _ , ax = plt . subplots ( figsize = ( 20 , 10 ) ) timestamps = sorted ( residency . keys ( ) ) x_max = len ( list ( residency . values ( ) ) [ 0 ] ) * 4096 for t in timestamps : offset_ms = ( t - timestamps [ 0 ] ) / 1e6 incore = [ i * 4096 for ( i , x ) in enumerate ( residency [ t ] ) if x ] outcore = [ i * 4096 for ( i , x ) in enumerate ( residency [ t ] ) if not x ] percentage = 100. * len ( incore ) / ( len ( incore ) + len ( outcore ) ) plt . text ( x_max , offset_ms , '%.1f%%' % percentage ) for ( d , color ) in ( ( incore , ( .2 , .6 , .05 , 1 ) ) , ( outcore , ( 1 , 0 , 0 , 1 ) ) ) : segments = [ [ ( x , offset_ms ) , ( x + 4096 , offset_ms ) ] for x in d ] colors = np . array ( [ color ] * len ( segments ) ) lc = mc . LineCollection ( segments , colors = colors , linewidths = 8 ) ax . add_collection ( lc ) plt . axvline ( start ) plt . axvline ( end ) plt . title ( 'Code residency vs time since startup.' ) plt . xlabel ( 'Code page offset (bytes)' ) plt . ylabel ( 'Time since startup (ms)' ) plt . ylim ( 0 , ymax = ( timestamps [ - 1 ] - timestamps [ 0 ] ) / 1e6 ) plt . xlim ( xmin = 0 , xmax = x_max ) plt . savefig ( output_filename , bbox_inches = 'tight' , dpi = 300 )
Creates a graph of residency.
Creates a graph of residency .
"""Creates a graph of residency.

  Args:
    data: (dict) As returned by ParseDump().
    output_filename: (str) Output filename.
  """
data
(dict) As returned by ParseDump().
( dict ) As returned by ParseDump () .
output_filename
(str) Output filename.
( str ) Output filename .