MCPcopy Index your code
hub / github.com/python/cpython / calc_histogram_table

Function calc_histogram_table

Tools/scripts/summarize_stats.py:1224–1258  ·  view source on GitHub ↗
(key: str, den: str | None = None)

Source from the content-addressed store, hash-verified

1222 ]
1223
1224 def calc_histogram_table(key: str, den: str | None = None) -> RowCalculator:
1225 def calc(stats: Stats) -> Rows:
1226 histogram = stats.get_histogram(key)
1227
1228 if den:
1229 denominator = stats.get(den)
1230 else:
1231 denominator = 0
1232 for _, v in histogram:
1233 denominator += v
1234
1235 rows: Rows = []
1236 for k, v in histogram:
1237 rows.append(
1238 (
1239 f"<= {k:,d}",
1240 Count(v),
1241 Ratio(v, denominator),
1242 )
1243 )
1244 # Don't include any leading and trailing zero entries
1245 start = 0
1246 end = len(rows) - 1
1247
1248 while start <= end:
1249 if rows[start][1] == 0:
1250 start += 1
1251 elif rows[end][1] == 0:
1252 end -= 1
1253 else:
1254 break
1255
1256 return rows[start:end+1]
1257
1258 return calc
1259
1260 def calc_unsupported_opcodes_table(stats: Stats) -> Rows:
1261 unsupported_opcodes = stats.get_opcode_stats("unsupported_opcode")

Callers 1

iter_optimization_tablesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…