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

Function optimization_section

Tools/scripts/summarize_stats.py:1191–1361  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1189
1190
1191def optimization_section() -> Section:
1192 def calc_optimization_table(stats: Stats) -> Rows:
1193 optimization_stats = stats.get_optimization_stats()
1194
1195 return [
1196 (
1197 label,
1198 Count(value),
1199 Ratio(value, den, percentage=label != "Uops executed"),
1200 )
1201 for label, (value, den) in optimization_stats.items()
1202 ]
1203
1204 def calc_optimizer_table(stats: Stats) -> Rows:
1205 optimizer_stats = stats.get_optimizer_stats()
1206
1207 return [
1208 (label, Count(value), Ratio(value, den))
1209 for label, (value, den) in optimizer_stats.items()
1210 ]
1211
1212 def calc_jit_memory_table(stats: Stats) -> Rows:
1213 jit_memory_stats = stats.get_jit_memory_stats()
1214
1215 return [
1216 (
1217 label,
1218 Count(value),
1219 Ratio(value, den, percentage=label != "Total memory size"),
1220 )
1221 for label, (value, den) in jit_memory_stats.items()
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:

Callers 1

summarize_stats.pyFile · 0.85

Calls 1

SectionClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…