Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print static file weight #1240

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions bin/compile-static.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import re
import shlex
from asyncio.subprocess import PIPE
from collections import deque
from dataclasses import dataclass, field
from pathlib import Path
from shutil import rmtree
Expand All @@ -58,7 +57,6 @@
import brotli
import tinycss2
import zopfli.gzip
from tinycss2.ast import AtRule, ParseError

repo_root = Path(__file__).parent.parent

Expand Down Expand Up @@ -128,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 @@ -141,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 @@ -152,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