MCPcopy Create free account
hub / github.com/FastLED/FastLED / main

Function main

ci/bin_bloat_attribute.py:181–229  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

179
180
181def main() -> int:
182 ranges = loadable_progbits_ranges()
183 print("Loaded PROGBITS+ALLOC sections:")
184 for lo, hi, n in ranges:
185 print(f" {n:<22} {hi - lo:>10,} bytes [0x{lo:08x}-0x{hi:08x})")
186 total = sum(hi - lo for lo, hi, _ in ranges)
187 print(f" TOTAL bin-shipped (PROGBITS+ALLOC): {total:,}")
188
189 syms = parse_nm()
190 in_bin = [(a, s, t, m) for a, s, t, m in syms if in_loaded(a, ranges)]
191 print(f"\nnm symbols that fall in shipped sections: {len(in_bin):,}")
192 print(f"Sum of nm symbol sizes: {sum(s for _, s, _, _ in in_bin):,}")
193
194 # addr2line batch
195 addrs = [a for a, _, _, _ in in_bin]
196 print("Running addr2line for source attribution...")
197 a2l = addr2line_batch(addrs)
198
199 # Group by file
200 by_cat: dict[str, int] = defaultdict(int)
201 by_file: dict[str, int] = defaultdict(int)
202 by_file_list: dict[str, list[tuple[int, str]]] = defaultdict(list)
203 for a, sz, t, m in in_bin:
204 f = a2l.get(a, "??")
205 cat = categorize(f, m)
206 by_cat[cat] += sz
207 by_file[f] += sz
208 by_file_list[f].append((sz, m))
209
210 bin_attributed = sum(by_cat.values())
211 print(f"\n=== Bytes by CATEGORY (source-file attribution) ===")
212 print(f" attributed total: {bin_attributed:,}")
213 for cat, sz in sorted(by_cat.items(), key=lambda kv: -kv[1]):
214 pct = 100.0 * sz / total
215 print(f" {cat:<28} {sz:>10,} {pct:>5.1f}% of bin")
216
217 print("\n=== Top 40 source files (by bytes contributed to bin) ===")
218 for f, sz in sorted(by_file.items(), key=lambda kv: -kv[1])[:40]:
219 print(f" {sz:>8,} {f}")
220
221 # FL drivers detail
222 print("\n=== Top FL/Channel/* files (driver-level breakdown) ===")
223 fl_files = [
224 (f, sz) for f, sz in by_file.items() if categorize(f, "").startswith("FL/")
225 ]
226 for f, sz in sorted(fl_files, key=lambda kv: -kv[1])[:30]:
227 print(f" {sz:>8,} {f} ({categorize(f, '')})")
228
229 return 0
230
231
232if __name__ == "__main__":

Callers 1

Calls 10

loadable_progbits_rangesFunction · 0.85
parse_nmFunction · 0.85
in_loadedFunction · 0.85
addr2line_batchFunction · 0.85
valuesMethod · 0.80
itemsMethod · 0.80
categorizeFunction · 0.70
printFunction · 0.50
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected