Skip to content

Commit

Permalink
Print total static file weight
Browse files Browse the repository at this point in the history
  • Loading branch information
twm committed Dec 4, 2024
1 parent 31f416a commit b82319d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions bin/compile-static.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def summarize(self) -> str:
"ORIGINAL ZOPFLI (.gz) BROTLI (.br) FILE",
"--------- --------------- -------------- ------------------------------------------",
]
base_sum = gz_sum = br_sum = 0

def pct(size, total) -> str:
if size is None:
Expand All @@ -139,6 +140,9 @@ def pct(size, total) -> str:
return f"{left:>9} {right:>5}"

for r in self._written:
base_sum += r.base_size
gz_sum += r.base_size if r.gz_size is None else r.gz_size
br_sum += r.base_size if r.gz_size is None else r.br_size
lines.append(
" ".join(
[
Expand All @@ -150,6 +154,17 @@ def pct(size, total) -> str:
)
)

lines.append(lines[1])
lines.append(
" ".join(
[
f"{base_sum:>9,d} ",
pct(gz_sum, base_sum),
pct(br_sum, base_sum),
" TOTAL",
]
)
)
return "\n".join(lines)


Expand Down

0 comments on commit b82319d

Please sign in to comment.