OLD | NEW |
1 #! /usr/bin/env python | 1 #! /usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import argparse | 6 import argparse |
7 import os | 7 import os |
8 import re | 8 import re |
9 import sys | 9 import sys |
10 | 10 |
11 from devil.android.sdk import dexdump | 11 from devil.android.sdk import dexdump |
12 from pylib import constants | 12 from pylib import constants |
13 | 13 |
14 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib', | 14 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib', |
15 'common')) | 15 'common')) |
16 import perf_tests_results_helper | 16 import perf_tests_results_helper # pylint: disable=import-error |
17 | 17 |
18 | 18 |
19 _METHOD_IDS_SIZE_RE = re.compile(r'^method_ids_size +: +(\d+)$') | 19 _METHOD_IDS_SIZE_RE = re.compile(r'^method_ids_size +: +(\d+)$') |
20 | 20 |
21 def MethodCount(dexfile): | 21 def MethodCount(dexfile): |
22 for line in dexdump.DexDump(dexfile, file_summary=True): | 22 for line in dexdump.DexDump(dexfile, file_summary=True): |
23 m = _METHOD_IDS_SIZE_RE.match(line) | 23 m = _METHOD_IDS_SIZE_RE.match(line) |
24 if m: | 24 if m: |
25 return m.group(1) | 25 return m.group(1) |
26 raise Exception('"method_ids_size" not found in dex dump of %s' % dexfile) | 26 raise Exception('"method_ids_size" not found in dex dump of %s' % dexfile) |
(...skipping 19 matching lines...) Expand all Loading... |
46 'and --apk-name was not provided.' % args.dexfile) | 46 'and --apk-name was not provided.' % args.dexfile) |
47 | 47 |
48 method_count = MethodCount(args.dexfile) | 48 method_count = MethodCount(args.dexfile) |
49 perf_tests_results_helper.PrintPerfResult( | 49 perf_tests_results_helper.PrintPerfResult( |
50 '%s_methods' % args.apk_name, 'total', [method_count], 'methods') | 50 '%s_methods' % args.apk_name, 'total', [method_count], 'methods') |
51 return 0 | 51 return 0 |
52 | 52 |
53 if __name__ == '__main__': | 53 if __name__ == '__main__': |
54 sys.exit(main()) | 54 sys.exit(main()) |
55 | 55 |
OLD | NEW |