blob: ad26959f3cce765290e0ffa1510e00bac7cb5667 [file] [log] [blame]
Mathias Rav92f33402018-05-22 14:26:45 +02001#!/usr/bin/env python
2# Copyright (c) 2018, 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
Rico Wind1f4172c2018-09-06 16:29:03 +02006import argparse
Mathias Rav92f33402018-05-22 14:26:45 +02007import os
8import sys
Ian Zernycded6802018-06-15 13:30:32 +02009
Rico Wind1f4172c2018-09-06 16:29:03 +020010import golem
Ian Zernycded6802018-06-15 13:30:32 +020011import minify_tool
12import toolhelper
Mathias Rav92f33402018-05-22 14:26:45 +020013import utils
14
Mathias Rav92f33402018-05-22 14:26:45 +020015PINNED_R8_JAR = os.path.join(utils.REPO_ROOT, 'third_party/r8/r8.jar')
Ian Zernycded6802018-06-15 13:30:32 +020016PINNED_PGR8_JAR = os.path.join(utils.REPO_ROOT, 'third_party/r8/r8-pg6.0.1.jar')
Mathias Rav92f33402018-05-22 14:26:45 +020017
Rico Wind1f4172c2018-09-06 16:29:03 +020018def parse_arguments(argv):
19 parser = argparse.ArgumentParser(
20 description = 'Run r8 bootstrap benchmarks.')
21 parser.add_argument('--golem',
22 help = 'Link in third party dependencies.',
23 default = False,
24 action = 'store_true')
25 return parser.parse_args(argv)
26
27
Ian Zernycded6802018-06-15 13:30:32 +020028def dex(input, output):
29 return_code = toolhelper.run(
30 'd8', [
31 input,
32 '--output', output,
33 '--lib', utils.RT_JAR,
34 '--min-api', '10000',
35 '--no-desugaring',
36 ],
37 debug=False,
38 build=False)
39 if return_code != 0:
40 sys.exit(return_code)
Mathias Rav92f33402018-05-22 14:26:45 +020041
42if __name__ == '__main__':
Rico Wind1f4172c2018-09-06 16:29:03 +020043 options = parse_arguments(sys.argv[1:])
44 if options.golem:
45 golem.link_third_party()
Ian Zernycded6802018-06-15 13:30:32 +020046 with utils.TempDir() as temp:
47 memory_file = os.path.join(temp, 'memory.dump')
48 r8_output = os.path.join(temp, 'r8.zip')
49 d8_r8_output = os.path.join(temp, 'd8r8.zip')
50 d8_pg_output = os.path.join(temp, 'd8pg.zip')
51
52 return_code = minify_tool.minify_tool(
53 input_jar=PINNED_R8_JAR,
54 output_jar=r8_output,
55 debug=False,
56 build=False,
57 track_memory_file=memory_file,
58 benchmark_name="BootstrapR8")
59 if return_code != 0:
60 sys.exit(return_code)
61
62 dex(r8_output, d8_r8_output)
63 print "BootstrapR8(CodeSize):", os.path.getsize(r8_output)
64 print "BootstrapR8Dex(CodeSize):", os.path.getsize(d8_r8_output)
65
66 dex(PINNED_PGR8_JAR, d8_pg_output)
Rico Wind77d2ffb2018-06-28 14:07:50 +020067 print "BootstrapR8PG(CodeSize):", os.path.getsize(PINNED_PGR8_JAR)
68 print "BootstrapR8PGDex(CodeSize):", os.path.getsize(d8_pg_output)
Ian Zernycded6802018-06-15 13:30:32 +020069
Rico Wind77d2ffb2018-06-28 14:07:50 +020070 sys.exit(0)