blob: aab63ed5882bbd52e6e5b6d47a1ff23de5ad5ff5 [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 Adamsen2434a4d2023-10-16 11:29:03 +020012
Christoffer Quist Adamsen4d38d032021-04-20 12:31:31 +020013def ParseOptions(argv):
Christoffer Quist Adamsen2434a4d2023-10-16 11:29:03 +020014 parser = optparse.OptionParser(usage='%prog [options] -- [D8 options]')
15 parser.add_option('-c',
16 '--commit-hash',
17 '--commit_hash',
18 help='Commit hash of D8 to use.',
19 default=None)
20 parser.add_option('--print-runtimeraw',
21 '--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('--version', help='Version of D8 to use.', default=None)
27 parser.add_option('--tag', help='Tag of D8 to use.', default=None)
28 return parser.parse_args(argv)
29
Christoffer Quist Adamsen4d38d032021-04-20 12:31:31 +020030
31def main(argv):
Christoffer Quist Adamsen2434a4d2023-10-16 11:29:03 +020032 (options, args) = ParseOptions(sys.argv)
33 d8_args = args[1:]
34 time_consumer = lambda duration: print_duration(duration, options)
35 return toolhelper.run('d8',
36 d8_args,
37 jar=utils.find_r8_jar_from_options(options),
38 main='com.android.tools.r8.D8',
39 time_consumer=time_consumer)
40
Christoffer Quist Adamsend7a5b722022-02-24 18:12:02 +010041
42def print_duration(duration, options):
Christoffer Quist Adamsen2434a4d2023-10-16 11:29:03 +020043 benchmark_name = options.print_runtimeraw
44 if benchmark_name:
45 print('%s-Total(RunTimeRaw): %s ms' % (benchmark_name, duration))
46
Christoffer Quist Adamsen4d38d032021-04-20 12:31:31 +020047
Mads Ager418d1ca2017-05-22 09:35:49 +020048if __name__ == '__main__':
Christoffer Quist Adamsen2434a4d2023-10-16 11:29:03 +020049 sys.exit(main(sys.argv[1:]))