tools/cygprofile/orderfile_generator_backend.py
def _NativeCodeMemoryBenchmark(self, apk):
    """Runs system_health.memory_mobile to assess native code memory footprint.

    Args:
      apk: (str) Path to the apk.

    Returns:
      results: ([int]) Values of native code memory footprint in bytes from the
                       benchmark results.
    """
    self._step_recorder.BeginStep("Running orderfile.memory_mobile")
    try:
      out_dir = tempfile.mkdtemp()
      self._profiler._RunCommand(['tools/perf/run_benchmark',
                                  '--device={}'.format(
                                      self._profiler._device.serial),
                                  '--browser=exact',
                                  '--output-format=csv',
                                  '--output-dir={}'.format(out_dir),
                                  '--reset-results',
                                  '--browser-executable={}'.format(apk),
                                  'orderfile.memory_mobile'])

      out_file_path = os.path.join(out_dir, 'results.csv')
      if not os.path.exists(out_file_path):
        raise Exception('Results file not found!')

      results = {}
      with open(out_file_path, 'r') as f:
        reader = csv.DictReader(f)
        for row in reader:
          if not row['name'].endswith('NativeCodeResidentMemory'):
            continue
          # Note: NativeCodeResidentMemory records a single sample from each
          # story run, so this average (reported as 'avg') is exactly the value
          # of that one sample. Each story is run multiple times, so this loop
          # will accumulate into a list all values for all runs of each story.
          results.setdefault(row['name'], {}).setdefault(
              row['stories'], []).append(row['avg'])

      if not results:
        raise Exception('Could not find relevant results')

      return results

    except Exception as e:
      return 'Error: ' + str(e)

    finally:
      shutil.rmtree(out_dir)
Runs system_health.memory_mobile to assess native code memory footprint.

    Args:
      apk: (str) Path to the apk.

    Returns:
      results: ([int]) Values of native code memory footprint in bytes from the
                       benchmark results.
    
Runs system_health.memory_mobile to assess native code memory footprint.
Runs system_health . memory_mobile to assess native code memory footprint .
def _NativeCodeMemoryBenchmark(self, apk):
    self._step_recorder.BeginStep("Running orderfile.memory_mobile")
    try:
      out_dir = tempfile.mkdtemp()
      self._profiler._RunCommand(['tools/perf/run_benchmark',
                                  '--device={}'.format(
                                      self._profiler._device.serial),
                                  '--browser=exact',
                                  '--output-format=csv',
                                  '--output-dir={}'.format(out_dir),
                                  '--reset-results',
                                  '--browser-executable={}'.format(apk),
                                  'orderfile.memory_mobile'])
      out_file_path = os.path.join(out_dir, 'results.csv')
      if not os.path.exists(out_file_path):
        raise Exception('Results file not found!')
      results = {}
      with open(out_file_path, 'r') as f:
        reader = csv.DictReader(f)
        for row in reader:
          if not row['name'].endswith('NativeCodeResidentMemory'):
            continue
          results.setdefault(row['name'], {}).setdefault(
              row['stories'], []).append(row['avg'])
      if not results:
        raise Exception('Could not find relevant results')
      return results
    except Exception as e:
      return 'Error: ' + str(e)
    finally:
      shutil.rmtree(out_dir)
def _NativeCodeMemoryBenchmark ( self , apk ) : self . _step_recorder . BeginStep ( "Running orderfile.memory_mobile" ) try : out_dir = tempfile . mkdtemp ( ) self . _profiler . _RunCommand ( [ 'tools/perf/run_benchmark' , '--device={}' . format ( self . _profiler . _device . serial ) , '--browser=exact' , '--output-format=csv' , '--output-dir={}' . format ( out_dir ) , '--reset-results' , '--browser-executable={}' . format ( apk ) , 'orderfile.memory_mobile' ] ) out_file_path = os . path . join ( out_dir , 'results.csv' ) if not os . path . exists ( out_file_path ) : raise Exception ( 'Results file not found!' ) results = { } with open ( out_file_path , 'r' ) as f : reader = csv . DictReader ( f ) for row in reader : if not row [ 'name' ] . endswith ( 'NativeCodeResidentMemory' ) : continue results . setdefault ( row [ 'name' ] , { } ) . setdefault ( row [ 'stories' ] , [ ] ) . append ( row [ 'avg' ] ) if not results : raise Exception ( 'Could not find relevant results' ) return results except Exception as e : return 'Error: ' + str ( e ) finally : shutil . rmtree ( out_dir )
Runs system_health.memory_mobile to assess native code memory footprint.
Runs system_health . memory_mobile to assess native code memory footprint .
"""Runs system_health.memory_mobile to assess native code memory footprint.

    Args:
      apk: (str) Path to the apk.

    Returns:
      results: ([int]) Values of native code memory footprint in bytes from the
                       benchmark results.
    """ # Note: NativeCodeResidentMemory records a single sample from each # story run, so this average (reported as 'avg') is exactly the value # of that one sample. Each story is run multiple times, so this loop # will accumulate into a list all values for all runs of each story.
([int]) Values of native code memory footprint in bytes from the
benchmark results.
( [ int ] ) Values of native code memory footprint in bytes from the benchmark results .
results
self
apk
(str) Path to the apk.
( str ) Path to the apk .