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

Unified Diff: build/android/resource_sizes.py

Issue 2969123002: Add deduplication logic to .pak files (Closed)
Patch Set: sizeof() 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') | no next file with comments »
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 76f03fb4e30f41c81589e574491823e04c8f171d..099f71dec8b6aff80dd142a974bb75c583b9d974 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698