Format python files using yapf
Change-Id: I8b7b97efb6bfdcceef9efc533cdaa0675ab7db40
diff --git a/tools/historic_memory_usage.py b/tools/historic_memory_usage.py
index 3ef2268..a40cf2a 100755
--- a/tools/historic_memory_usage.py
+++ b/tools/historic_memory_usage.py
@@ -20,60 +20,64 @@
APPS = ['gmscore', 'nest', 'youtube', 'gmail', 'chrome']
COMPILERS = ['d8', 'r8']
+
def ParseOptions(argv):
- result = optparse.OptionParser()
- result.add_option('--compiler',
- help='The compiler to use',
- default='d8',
- choices=COMPILERS)
- result.add_option('--app',
- help='What app to run on',
- default='gmail',
- choices=APPS)
- result.add_option('--top',
- default=historic_run.top_or_default(),
- help='The most recent commit to test')
- result.add_option('--bottom',
- help='The oldest commit to test')
- result.add_option('--output',
- default='build',
- help='Directory where to output results')
- result.add_option('--timeout',
- type=int,
- default=0,
- help='Set timeout instead of waiting for OOM.')
- return result.parse_args(argv)
+ result = optparse.OptionParser()
+ result.add_option('--compiler',
+ help='The compiler to use',
+ default='d8',
+ choices=COMPILERS)
+ result.add_option('--app',
+ help='What app to run on',
+ default='gmail',
+ choices=APPS)
+ result.add_option('--top',
+ default=historic_run.top_or_default(),
+ help='The most recent commit to test')
+ result.add_option('--bottom', help='The oldest commit to test')
+ result.add_option('--output',
+ default='build',
+ help='Directory where to output results')
+ result.add_option('--timeout',
+ type=int,
+ default=0,
+ help='Set timeout instead of waiting for OOM.')
+ return result.parse_args(argv)
+
def make_run_on_app_command(options):
- return lambda commit: run_on_app(options, commit)
+ return lambda commit: run_on_app(options, commit)
+
def run_on_app(options, commit):
- app = options.app
- compiler = options.compiler
- cmd = ['tools/run_on_app.py',
- '--app', app,
- '--compiler', compiler,
- '--timeout', str(options.timeout),
- '--no-build', '--find-min-xmx']
- stdout = subprocess.check_output(cmd)
- output_path = options.output or 'build'
- time_commit = '%s_%s' % (commit.timestamp, commit.git_hash)
- time_commit_path = os.path.join(output_path, time_commit)
- if not os.path.exists(time_commit_path):
- os.makedirs(time_commit_path)
- stdout_path = os.path.join(time_commit_path, 'stdout')
- with open(stdout_path, 'w') as f:
- f.write(stdout)
- print('Wrote stdout to: %s' % stdout_path)
+ app = options.app
+ compiler = options.compiler
+ cmd = [
+ 'tools/run_on_app.py', '--app', app, '--compiler', compiler,
+ '--timeout',
+ str(options.timeout), '--no-build', '--find-min-xmx'
+ ]
+ stdout = subprocess.check_output(cmd)
+ output_path = options.output or 'build'
+ time_commit = '%s_%s' % (commit.timestamp, commit.git_hash)
+ time_commit_path = os.path.join(output_path, time_commit)
+ if not os.path.exists(time_commit_path):
+ os.makedirs(time_commit_path)
+ stdout_path = os.path.join(time_commit_path, 'stdout')
+ with open(stdout_path, 'w') as f:
+ f.write(stdout)
+ print('Wrote stdout to: %s' % stdout_path)
+
def main(argv):
- (options, args) = ParseOptions(argv)
- if not options.app:
- raise Exception('Please specify an app')
- top = historic_run.top_or_default(options.top)
- bottom = historic_run.bottom_or_default(options.bottom)
- command = make_run_on_app_command(options)
- historic_run.run(command, top, bottom)
+ (options, args) = ParseOptions(argv)
+ if not options.app:
+ raise Exception('Please specify an app')
+ top = historic_run.top_or_default(options.top)
+ bottom = historic_run.bottom_or_default(options.bottom)
+ command = make_run_on_app_command(options)
+ historic_run.run(command, top, bottom)
+
if __name__ == '__main__':
- sys.exit(main(sys.argv[1:]))
+ sys.exit(main(sys.argv[1:]))