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
4 # found in the LICENSE file.
11 from pylib
import constants
12 from pylib
.sdk
import dexdump
14 sys
.path
.append(os
.path
.join(constants
.DIR_SOURCE_ROOT
, 'build', 'util', 'lib',
16 import perf_tests_results_helper
19 _METHOD_IDS_SIZE_RE
= re
.compile(r
'^method_ids_size +: +(\d+)$')
21 def MethodCount(dexfile
):
22 for line
in dexdump
.DexDump(dexfile
, file_summary
=True):
23 m
= _METHOD_IDS_SIZE_RE
.match(line
)
26 raise Exception('"method_ids_size" not found in dex dump of %s' % dexfile
)
29 parser
= argparse
.ArgumentParser()
31 '--apk-name', help='Name of the APK to which the dexfile corresponds.')
32 parser
.add_argument('dexfile')
34 args
= parser
.parse_args()
37 dirname
, basename
= os
.path
.split(args
.dexfile
)
40 args
.apk_name
= basename
42 dirname
, basename
= os
.path
.split(dirname
)
45 'Unable to determine apk name from %s, '
46 'and --apk-name was not provided.' % args
.dexfile
)
48 method_count
= MethodCount(args
.dexfile
)
49 perf_tests_results_helper
.PrintPerfResult(
50 '%s_methods' % args
.apk_name
, 'total', [method_count
], 'methods')
53 if __name__
== '__main__':