blob: 90834f826d848ec0b51ea294008254257f2adaf5 [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 +020015
Rico Wind1f4172c2018-09-06 16:29:03 +020016def parse_arguments(argv):
17 parser = argparse.ArgumentParser(
18 description = 'Run r8 bootstrap benchmarks.')
19 parser.add_argument('--golem',
20 help = 'Link in third party dependencies.',
21 default = False,
22 action = 'store_true')
23 return parser.parse_args(argv)
24
25
Ian Zernycded6802018-06-15 13:30:32 +020026def dex(input, output):
27 return_code = toolhelper.run(
28 'd8', [
29 input,
30 '--output', output,
31 '--lib', utils.RT_JAR,
32 '--min-api', '10000',
33 '--no-desugaring',
34 ],
35 debug=False,
36 build=False)
37 if return_code != 0:
38 sys.exit(return_code)
Mathias Rav92f33402018-05-22 14:26:45 +020039
40if __name__ == '__main__':
Rico Wind1f4172c2018-09-06 16:29:03 +020041 options = parse_arguments(sys.argv[1:])
42 if options.golem:
43 golem.link_third_party()
Ian Zernycded6802018-06-15 13:30:32 +020044 with utils.TempDir() as temp:
45 memory_file = os.path.join(temp, 'memory.dump')
46 r8_output = os.path.join(temp, 'r8.zip')
47 d8_r8_output = os.path.join(temp, 'd8r8.zip')
48 d8_pg_output = os.path.join(temp, 'd8pg.zip')
49
50 return_code = minify_tool.minify_tool(
Morten Krogh-Jespersen38c7ca02019-02-04 10:39:57 +010051 input_jar=utils.PINNED_R8_JAR,
Ian Zernycded6802018-06-15 13:30:32 +020052 output_jar=r8_output,
53 debug=False,
54 build=False,
55 track_memory_file=memory_file,
56 benchmark_name="BootstrapR8")
57 if return_code != 0:
58 sys.exit(return_code)
59
60 dex(r8_output, d8_r8_output)
Morten Krogh-Jespersen16e925d2019-01-25 14:40:38 +010061 print "BootstrapR8(CodeSize):", utils.uncompressed_size(r8_output)
62 print "BootstrapR8Dex(CodeSize):", utils.uncompressed_size(d8_r8_output)
Ian Zernycded6802018-06-15 13:30:32 +020063
Morten Krogh-Jespersen38c7ca02019-02-04 10:39:57 +010064 dex(utils.PINNED_PGR8_JAR, d8_pg_output)
65 print "BootstrapR8PG(CodeSize):", utils.uncompressed_size(
66 utils.PINNED_PGR8_JAR)
Morten Krogh-Jespersen16e925d2019-01-25 14:40:38 +010067 print "BootstrapR8PGDex(CodeSize):", utils.uncompressed_size(d8_pg_output)
Ian Zernycded6802018-06-15 13:30:32 +020068
Rico Wind77d2ffb2018-06-28 14:07:50 +020069 sys.exit(0)