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 shutil | 9 import shutil |
10 import sys | 10 import sys |
11 import tempfile | 11 import tempfile |
12 import zipfile | 12 import zipfile |
13 | 13 |
| 14 import devil_chromium |
14 from devil.android.sdk import dexdump | 15 from devil.android.sdk import dexdump |
15 from pylib import constants | 16 from pylib.constants import host_paths |
16 | 17 |
17 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib', | 18 sys.path.append(os.path.join(host_paths.DIR_SOURCE_ROOT, 'build', 'util', 'lib', |
18 'common')) | 19 'common')) |
19 import perf_tests_results_helper # pylint: disable=import-error | 20 import perf_tests_results_helper # pylint: disable=import-error |
20 | 21 |
21 | 22 |
22 _METHOD_IDS_SIZE_RE = re.compile(r'^method_ids_size +: +(\d+)$') | 23 _METHOD_IDS_SIZE_RE = re.compile(r'^method_ids_size +: +(\d+)$') |
23 | 24 |
24 def ExtractIfZip(dexfile, tmpdir): | 25 def ExtractIfZip(dexfile, tmpdir): |
25 if not dexfile.endswith('.zip'): | 26 if not dexfile.endswith('.zip'): |
26 return [dexfile] | 27 return [dexfile] |
27 | 28 |
(...skipping 18 matching lines...) Expand all Loading... |
46 shutil.rmtree(tmpdir) | 47 shutil.rmtree(tmpdir) |
47 | 48 |
48 def main(): | 49 def main(): |
49 parser = argparse.ArgumentParser() | 50 parser = argparse.ArgumentParser() |
50 parser.add_argument( | 51 parser.add_argument( |
51 '--apk-name', help='Name of the APK to which the dexfile corresponds.') | 52 '--apk-name', help='Name of the APK to which the dexfile corresponds.') |
52 parser.add_argument('dexfile') | 53 parser.add_argument('dexfile') |
53 | 54 |
54 args = parser.parse_args() | 55 args = parser.parse_args() |
55 | 56 |
| 57 devil_chromium.Initialize() |
| 58 |
56 if not args.apk_name: | 59 if not args.apk_name: |
57 dirname, basename = os.path.split(args.dexfile) | 60 dirname, basename = os.path.split(args.dexfile) |
58 while basename: | 61 while basename: |
59 if 'apk' in basename: | 62 if 'apk' in basename: |
60 args.apk_name = basename | 63 args.apk_name = basename |
61 break | 64 break |
62 dirname, basename = os.path.split(dirname) | 65 dirname, basename = os.path.split(dirname) |
63 else: | 66 else: |
64 parser.error( | 67 parser.error( |
65 'Unable to determine apk name from %s, ' | 68 'Unable to determine apk name from %s, ' |
66 'and --apk-name was not provided.' % args.dexfile) | 69 'and --apk-name was not provided.' % args.dexfile) |
67 | 70 |
68 method_count = MethodCount(args.dexfile) | 71 method_count = MethodCount(args.dexfile) |
69 perf_tests_results_helper.PrintPerfResult( | 72 perf_tests_results_helper.PrintPerfResult( |
70 '%s_methods' % args.apk_name, 'total', [method_count], 'methods') | 73 '%s_methods' % args.apk_name, 'total', [method_count], 'methods') |
71 return 0 | 74 return 0 |
72 | 75 |
73 if __name__ == '__main__': | 76 if __name__ == '__main__': |
74 sys.exit(main()) | 77 sys.exit(main()) |
75 | 78 |
OLD | NEW |