blob: 21bb73859bae97ccbd8409908406ab317c9a41f1 [file] [log] [blame]
Morten Krogh-Jespersenafd858c2020-03-11 11:09:19 +01001#!/usr/bin/env python
2# Copyright (c) 2020, 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
6import argparse
7import jdk
8import golem
9import os
10import subprocess
11import sys
12import time
13import toolhelper
14import utils
15
16RETRACERS = ['r8', 'proguard', 'remapper']
17
18def parse_arguments(argv):
19 parser = argparse.ArgumentParser(
20 description = 'Run r8 retrace bootstrap benchmarks.')
21 parser.add_argument('--golem',
22 help = 'Link in third party dependencies.',
23 default = False,
24 action = 'store_true')
25 parser.add_argument('--ignore-java-version',
26 help='Do not check java version',
27 default=False,
28 action='store_true')
29 parser.add_argument('--print-runtimeraw',
30 metavar='BENCHMARKNAME',
31 help='Print the line \'<BENCHMARKNAME>(RunTimeRaw):' +
32 ' <elapsed> ms\' at the end where <elapsed> is' +
33 ' the elapsed time in milliseconds.')
34 parser.add_argument('--retracer',
35 help='The retracer to use',
36 choices=RETRACERS,
37 required=True)
38 options = parser.parse_args(argv)
39 return options
40
41
42def run_retrace(options, temp):
43 if options.retracer == 'r8':
44 retracer_args = [
45 '-cp', utils.R8LIB_JAR, 'com.android.tools.r8.retrace.Retrace']
46 elif options.retracer == 'proguard':
47 retracer_args = ['-jar',
48 os.path.join(
49 utils.THIRD_PARTY,
50 'proguard',
51 'proguard6.0.1',
52 'lib',
53 'retrace.jar')]
54 elif options.retracer == 'remapper':
55 retracer_args = ['-jar',
56 os.path.join(
57 utils.THIRD_PARTY,
58 'remapper',
59 'remapper_deploy.jar')]
60 else:
61 assert False, "Unexpected retracer " + options.retracer
62 retrace_args = [jdk.GetJavaExecutable()] + retracer_args + [
63 os.path.join(utils.THIRD_PARTY, 'retrace_benchmark', 'r8lib.jar.map'),
64 os.path.join(utils.THIRD_PARTY, 'retrace_benchmark', 'stacktrace.txt')]
65 utils.PrintCmd(retrace_args)
66 t0 = time.time()
Rico Wind69d5b0e2020-04-06 10:56:23 +020067 subprocess.check_call(retrace_args)
Morten Krogh-Jespersenafd858c2020-03-11 11:09:19 +010068 t1 = time.time()
69 if options.print_runtimeraw:
70 print('{}(RunTimeRaw): {} ms'
71 .format(options.print_runtimeraw, 1000.0 * (t1 - t0)))
72
73
74if __name__ == '__main__':
75 options = parse_arguments(sys.argv[1:])
76 if options.golem:
77 golem.link_third_party()
78 if not options.ignore_java_version:
79 utils.check_java_version()
80 with utils.TempDir() as temp:
81 run_retrace(options, temp)