Skip to content

Commit 75e147f

Browse files
committed
Address Brandt's feedback.
1 parent d5618d7 commit 75e147f

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

Tools/scripts/summarize_stats.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,20 +1220,27 @@ def calc(stats: Stats) -> Rows:
12201220
denominator += v
12211221

12221222
rows: Rows = []
1223-
last_non_zero = 0
12241223
for k, v in histogram:
1225-
if v != 0:
1226-
last_non_zero = len(rows)
12271224
rows.append(
12281225
(
12291226
f"<= {k:,d}",
12301227
Count(v),
12311228
Ratio(v, denominator),
12321229
)
12331230
)
1234-
# Don't include any zero entries at the end
1235-
rows = rows[: last_non_zero + 1]
1236-
return rows
1231+
# Don't include any leading and trailing zero entries
1232+
start = 0
1233+
end = len(rows) - 1
1234+
1235+
while start <= end:
1236+
if rows[start][1] == 0:
1237+
start += 1
1238+
elif rows[end][1] == 0:
1239+
end -= 1
1240+
else:
1241+
break
1242+
1243+
return rows[start:end+1]
12371244

12381245
return calc
12391246

@@ -1269,7 +1276,7 @@ def iter_optimization_tables(base_stats: Stats, head_stats: Stats | None = None)
12691276
yield Table(("", "Count:", "Ratio:"), calc_optimizer_table, JoinMode.CHANGE)
12701277
yield Section(
12711278
"JIT memory stats",
1272-
"",
1279+
"JIT memory stats",
12731280
[
12741281
Table(
12751282
("", "Size (bytes):", "Ratio:"),
@@ -1280,7 +1287,7 @@ def iter_optimization_tables(base_stats: Stats, head_stats: Stats | None = None)
12801287
)
12811288
yield Section(
12821289
"JIT trace total memory histogram",
1283-
"",
1290+
"JIT trace total memory histogram",
12841291
[
12851292
Table(
12861293
("Size (bytes)", "Count", "Ratio:"),

0 commit comments

Comments
 (0)