blob: c2dfe8763e46940590fd48aca65a40300dcd6985 [file] [log] [blame]
Ian Zernydcb172e2022-02-22 15:36:45 +01001#!/usr/bin/env python3
Mads Ager418d1ca2017-05-22 09:35:49 +02002# Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
3# for details. All rights reserved. Use of this source code is governed by a
4# BSD-style license that can be found in the LICENSE file.
5
Christoffer Quist Adamsen4d38d032021-04-20 12:31:31 +02006import utils
7
8import optparse
Mads Ager418d1ca2017-05-22 09:35:49 +02009import sys
Mathias Ravdd6a6de2018-05-18 10:18:33 +020010import toolhelper
Mads Ager418d1ca2017-05-22 09:35:49 +020011
Christoffer Quist Adamsen4d38d032021-04-20 12:31:31 +020012def ParseOptions(argv):
13 parser = optparse.OptionParser(usage='%prog [options] -- [D8 options]')
14 parser.add_option(
15 '-c',
16 '--commit-hash',
17 '--commit_hash',
18 help='Commit hash of D8 to use.',
19 default=None)
20 parser.add_option(
Christoffer Quist Adamsend7a5b722022-02-24 18:12:02 +010021 '--print-runtimeraw', '--print_runtimeraw',
22 metavar='BENCHMARKNAME',
23 help='Print the line \'<BENCHMARKNAME>(RunTimeRaw):' +
24 ' <elapsed> ms\' at the end where <elapsed> is' +
25 ' the elapsed time in milliseconds.')
26 parser.add_option(
Christoffer Quist Adamsen4d38d032021-04-20 12:31:31 +020027 '--version',
28 help='Version of D8 to use.',
29 default=None)
30 parser.add_option(
31 '--tag',
32 help='Tag of D8 to use.',
33 default=None)
34 return parser.parse_args(argv)
35
36def main(argv):
37 (options, args) = ParseOptions(sys.argv)
38 d8_args = args[1:]
Christoffer Quist Adamsend7a5b722022-02-24 18:12:02 +010039 time_consumer = lambda duration : print_duration(duration, options)
Christoffer Quist Adamsen4d38d032021-04-20 12:31:31 +020040 return toolhelper.run(
41 'd8',
42 d8_args,
43 jar=utils.find_r8_jar_from_options(options),
Christoffer Quist Adamsend7a5b722022-02-24 18:12:02 +010044 main='com.android.tools.r8.D8',
45 time_consumer=time_consumer)
46
47def print_duration(duration, options):
48 benchmark_name = options.print_runtimeraw
49 if benchmark_name:
50 print('%s-Total(RunTimeRaw): %s ms' % (benchmark_name, duration))
Christoffer Quist Adamsen4d38d032021-04-20 12:31:31 +020051
Mads Ager418d1ca2017-05-22 09:35:49 +020052if __name__ == '__main__':
Christoffer Quist Adamsen4d38d032021-04-20 12:31:31 +020053 sys.exit(main(sys.argv[1:]))