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

Unified Diff: build/android/resource_sizes.py

Issue 2969123002: Add deduplication logic to .pak files (Closed)
Patch Set: fix resource_sizes computation Created 3 years, 5 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 | tools/grit/grit/format/data_pack.py » ('j') | tools/grit/grit/format/data_pack.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/resource_sizes.py
diff --git a/build/android/resource_sizes.py b/build/android/resource_sizes.py
index c93f6758c1fec8e7cdae1b6d66880427ddefc8d1..f6e7e42d57adc05ee741b39261e09427db539dbc 100755
--- a/build/android/resource_sizes.py
+++ b/build/android/resource_sizes.py
@@ -562,12 +562,17 @@ def PrintPakAnalysis(apk_filename, min_pak_resource_size):
# Calculate aggregate stats about resources across pak files.
resource_count_map = collections.defaultdict(int)
resource_size_map = collections.defaultdict(int)
+ seen_data_ids = set()
+ alias_overhead_bytes = 4
resource_overhead_bytes = 6
for pak in paks:
- for r in pak.resources:
- resource_count_map[r] += 1
- resource_size_map[r] += len(pak.resources[r]) + resource_overhead_bytes
-
+ for k, v in pak.resources.iteritems():
+ resource_count_map[k] += 1
+ if id(v) not in seen_data_ids:
+ seen_data_ids.add(id(v))
+ resource_size_map[k] += resource_overhead_bytes + len(v)
+ else:
+ resource_size_map[k] += alias_overhead_bytes
# Output the overall resource summary.
total_resource_size = sum(resource_size_map.values())
total_resource_count = len(resource_count_map)
« no previous file with comments | « no previous file | tools/grit/grit/format/data_pack.py » ('j') | tools/grit/grit/format/data_pack.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698