tools/android/appstats.py
def PrettyGraph(self, file_path, snapshots):
    """Creates a pdf graph of |snapshots| (a list of DeviceSnapshots) at
    |file_path|.  This currently only shows memory stats and no network
    stats."""
    # Import these here so the rest of the functionality doesn't rely on
    # matplotlib
    from matplotlib import pyplot
    from matplotlib.backends.backend_pdf import PdfPages

    if not file_path or not snapshots:
      return

    pids = self.__FindPidsForSnapshotList(snapshots)

    pp = PdfPages(file_path)
    for (userid, pid, name) in pids:
      figure = pyplot.figure()
      ax = figure.add_subplot(1, 1, 1)
      ax.set_xlabel('Time (s)')
      ax.set_ylabel('MB')
      ax.set_title(name + ' (' + pid + ')')

      mem_list = [[] for x in range(len(self.__MEMORY_COLUMN_TITLES))]
      timestamps = []

      for snapshot in snapshots:
        results = snapshot.GetMemoryResults(pid)
        if not results:
          continue

        timestamps.append(round(snapshot.GetTimestamp(), 2))

        assert len(results) == len(self.__MEMORY_COLUMN_TITLES)
        for idx, result in enumerate(results):
          mem_list[idx].append(result)

      colors = []
      for data in mem_list:
        colors.append(ax.plot(timestamps, data)[0])
        for i in range(len(timestamps)):
          ax.annotate(data[i], xy=(timestamps[i], data[i]))
      figure.legend(colors, self.__MEMORY_COLUMN_TITLES)
      pp.savefig()
    pp.close()
Creates a pdf graph of |snapshots| (a list of DeviceSnapshots) at
    |file_path|.  This currently only shows memory stats and no network
    stats.
Creates a pdf graph of |snapshots| (a list of DeviceSnapshots) at
|file_path|.  This currently only shows memory stats and no network
stats.
Creates a pdf graph of |snapshots| ( a list of DeviceSnapshots ) at |file_path| . This currently only shows memory stats and no network stats .
def PrettyGraph(self, file_path, snapshots):
    from matplotlib import pyplot
    from matplotlib.backends.backend_pdf import PdfPages
    if not file_path or not snapshots:
      return
    pids = self.__FindPidsForSnapshotList(snapshots)
    pp = PdfPages(file_path)
    for (userid, pid, name) in pids:
      figure = pyplot.figure()
      ax = figure.add_subplot(1, 1, 1)
      ax.set_xlabel('Time (s)')
      ax.set_ylabel('MB')
      ax.set_title(name + ' (' + pid + ')')
      mem_list = [[] for x in range(len(self.__MEMORY_COLUMN_TITLES))]
      timestamps = []
      for snapshot in snapshots:
        results = snapshot.GetMemoryResults(pid)
        if not results:
          continue
        timestamps.append(round(snapshot.GetTimestamp(), 2))
        assert len(results) == len(self.__MEMORY_COLUMN_TITLES)
        for idx, result in enumerate(results):
          mem_list[idx].append(result)
      colors = []
      for data in mem_list:
        colors.append(ax.plot(timestamps, data)[0])
        for i in range(len(timestamps)):
          ax.annotate(data[i], xy=(timestamps[i], data[i]))
      figure.legend(colors, self.__MEMORY_COLUMN_TITLES)
      pp.savefig()
    pp.close()
def PrettyGraph ( self , file_path , snapshots ) : from matplotlib import pyplot from matplotlib . backends . backend_pdf import PdfPages if not file_path or not snapshots : return pids = self . __FindPidsForSnapshotList ( snapshots ) pp = PdfPages ( file_path ) for ( userid , pid , name ) in pids : figure = pyplot . figure ( ) ax = figure . add_subplot ( 1 , 1 , 1 ) ax . set_xlabel ( 'Time (s)' ) ax . set_ylabel ( 'MB' ) ax . set_title ( name + ' (' + pid + ')' ) mem_list = [ [ ] for x in range ( len ( self . __MEMORY_COLUMN_TITLES ) ) ] timestamps = [ ] for snapshot in snapshots : results = snapshot . GetMemoryResults ( pid ) if not results : continue timestamps . append ( round ( snapshot . GetTimestamp ( ) , 2 ) ) assert len ( results ) == len ( self . __MEMORY_COLUMN_TITLES ) for idx , result in enumerate ( results ) : mem_list [ idx ] . append ( result ) colors = [ ] for data in mem_list : colors . append ( ax . plot ( timestamps , data ) [ 0 ] ) for i in range ( len ( timestamps ) ) : ax . annotate ( data [ i ] , xy = ( timestamps [ i ] , data [ i ] ) ) figure . legend ( colors , self . __MEMORY_COLUMN_TITLES ) pp . savefig ( ) pp . close ( )
Creates a pdf graph of |snapshots| (a list of DeviceSnapshots) at
|file_path|.
Creates a pdf graph of |snapshots| ( a list of DeviceSnapshots ) at |file_path| .
"""Creates a pdf graph of |snapshots| (a list of DeviceSnapshots) at
    |file_path|.  This currently only shows memory stats and no network
    stats.""" # Import these here so the rest of the functionality doesn't rely on # matplotlib
self
file_path
snapshots