Mathias Rav | 92f3340 | 2018-05-22 14:26:45 +0200 | [diff] [blame] | 1 | #!/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 Wind | 1f4172c | 2018-09-06 16:29:03 +0200 | [diff] [blame] | 6 | import argparse |
Mathias Rav | 92f3340 | 2018-05-22 14:26:45 +0200 | [diff] [blame] | 7 | import os |
| 8 | import sys |
Ian Zerny | cded680 | 2018-06-15 13:30:32 +0200 | [diff] [blame] | 9 | |
Rico Wind | 1f4172c | 2018-09-06 16:29:03 +0200 | [diff] [blame] | 10 | import golem |
Ian Zerny | cded680 | 2018-06-15 13:30:32 +0200 | [diff] [blame] | 11 | import minify_tool |
| 12 | import toolhelper |
Mathias Rav | 92f3340 | 2018-05-22 14:26:45 +0200 | [diff] [blame] | 13 | import utils |
| 14 | |
Mathias Rav | 92f3340 | 2018-05-22 14:26:45 +0200 | [diff] [blame] | 15 | |
Rico Wind | 1f4172c | 2018-09-06 16:29:03 +0200 | [diff] [blame] | 16 | def 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 Zerny | cded680 | 2018-06-15 13:30:32 +0200 | [diff] [blame] | 26 | def 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 Rav | 92f3340 | 2018-05-22 14:26:45 +0200 | [diff] [blame] | 39 | |
| 40 | if __name__ == '__main__': |
Rico Wind | 1f4172c | 2018-09-06 16:29:03 +0200 | [diff] [blame] | 41 | options = parse_arguments(sys.argv[1:]) |
| 42 | if options.golem: |
| 43 | golem.link_third_party() |
Ian Zerny | cded680 | 2018-06-15 13:30:32 +0200 | [diff] [blame] | 44 | 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-Jespersen | 38c7ca0 | 2019-02-04 10:39:57 +0100 | [diff] [blame] | 51 | input_jar=utils.PINNED_R8_JAR, |
Ian Zerny | cded680 | 2018-06-15 13:30:32 +0200 | [diff] [blame] | 52 | 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-Jespersen | 16e925d | 2019-01-25 14:40:38 +0100 | [diff] [blame] | 61 | print "BootstrapR8(CodeSize):", utils.uncompressed_size(r8_output) |
| 62 | print "BootstrapR8Dex(CodeSize):", utils.uncompressed_size(d8_r8_output) |
Ian Zerny | cded680 | 2018-06-15 13:30:32 +0200 | [diff] [blame] | 63 | |
Morten Krogh-Jespersen | 38c7ca0 | 2019-02-04 10:39:57 +0100 | [diff] [blame] | 64 | dex(utils.PINNED_PGR8_JAR, d8_pg_output) |
| 65 | print "BootstrapR8PG(CodeSize):", utils.uncompressed_size( |
| 66 | utils.PINNED_PGR8_JAR) |
Morten Krogh-Jespersen | 16e925d | 2019-01-25 14:40:38 +0100 | [diff] [blame] | 67 | print "BootstrapR8PGDex(CodeSize):", utils.uncompressed_size(d8_pg_output) |
Ian Zerny | cded680 | 2018-06-15 13:30:32 +0200 | [diff] [blame] | 68 | |
Rico Wind | 77d2ffb | 2018-06-28 14:07:50 +0200 | [diff] [blame] | 69 | sys.exit(0) |