Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(679)

Unified Diff: build/android/method_count.py

Issue 2100703002: 🎍 Add field counts to method_count.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/method_count.py
diff --git a/build/android/method_count.py b/build/android/method_count.py
index 6569f0eeba50f2389dd6509ed874ebf7ddd68e17..264480cd6944107800c499a62419a6eac37a5e2a 100755
--- a/build/android/method_count.py
+++ b/build/android/method_count.py
@@ -20,9 +20,11 @@ sys.path.append(os.path.join(host_paths.DIR_SOURCE_ROOT, 'build', 'util', 'lib',
import perf_tests_results_helper # pylint: disable=import-error
+_FIELD_IDS_SIZE_RE = re.compile(r'^field_ids_size +: +(\d+)$')
_METHOD_IDS_SIZE_RE = re.compile(r'^method_ids_size +: +(\d+)$')
-def ExtractIfZip(dexfile, tmpdir):
+
+def _ExtractIfZip(dexfile, tmpdir):
if not os.path.splitext(dexfile)[1] in ('.zip', '.apk', '.jar'):
return [dexfile]
@@ -32,21 +34,41 @@ def ExtractIfZip(dexfile, tmpdir):
return [os.path.join(tmpdir, f) for f in dex_files]
-def SingleMethodCount(dexfile):
- for line in dexdump.DexDump(dexfile, file_summary=True):
- m = _METHOD_IDS_SIZE_RE.match(line)
- if m:
- return m.group(1)
- raise Exception('"method_ids_size" not found in dex dump of %s' % dexfile)
-def MethodCount(dexfile):
+def _SingleMethodAndFieldCount(dex_path):
jbudorick 2016/06/27 09:21:27 I forget what else is in the dexdump -- would we p
+ fields = None
+ methods = None
+ for line in dexdump.DexDump(dex_path, file_summary=True):
+ if fields is None:
+ m = _FIELD_IDS_SIZE_RE.match(line)
+ if m:
+ fields = int(m.group(1))
+ if methods is None:
+ m = _METHOD_IDS_SIZE_RE.match(line)
+ if m:
+ methods = int(m.group(1))
+ if fields is None:
+ raise Exception('"fields_ids_size" not found in dex dump of %s' % dex_path)
+ if methods is None:
+ raise Exception('"method_ids_size" not found in dex dump of %s' % dex_path)
+ return fields, methods
jbudorick 2016/06/27 09:21:27 nit: If this stays "SingleMethodAndFieldCount", it
+
+
+def _MethodAndFieldCount(dexfile):
tmpdir = tempfile.mkdtemp(suffix='_dex_extract')
- multidex_file_list = ExtractIfZip(dexfile, tmpdir)
+ multidex_file_list = _ExtractIfZip(dexfile, tmpdir)
try:
- return sum(int(SingleMethodCount(d)) for d in multidex_file_list)
+ total_fields = 0
+ total_methods = 0
+ for path in multidex_file_list:
+ f, m = _SingleMethodAndFieldCount(path)
+ total_fields += f
+ total_methods += m
+ return total_fields, total_methods
jbudorick 2016/06/27 09:21:26 nit: same
finally:
shutil.rmtree(tmpdir)
+
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
@@ -69,7 +91,9 @@ def main():
'Unable to determine apk name from %s, '
'and --apk-name was not provided.' % args.dexfile)
- method_count = MethodCount(args.dexfile)
+ field_count, method_count = _MethodAndFieldCount(args.dexfile)
+ perf_tests_results_helper.PrintPerfResult(
jbudorick 2016/06/27 09:21:26 kinda odd to have method_count.py doing this as we
+ '%s_fields' % args.apk_name, 'total', [field_count], 'fields')
perf_tests_results_helper.PrintPerfResult(
'%s_methods' % args.apk_name, 'total', [method_count], 'methods')
return 0
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698