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

Function calc_pair_count_table

Tools/scripts/summarize_stats.py:794–813  ·  view source on GitHub ↗
(stats: Stats)

Source from the content-addressed store, hash-verified

792
793def pair_count_section(prefix: str, title=None) -> Section:
794 def calc_pair_count_table(stats: Stats) -> Rows:
795 opcode_stats = stats.get_opcode_stats(prefix)
796 pair_counts = opcode_stats.get_pair_counts()
797 total = opcode_stats.get_total_execution_count()
798
799 cumulative = 0
800 rows: Rows = []
801 for (opcode_i, opcode_j), count in itertools.islice(
802 sorted(pair_counts.items(), key=itemgetter(1), reverse=True), 100
803 ):
804 cumulative += count
805 rows.append(
806 (
807 f"{opcode_i} {opcode_j}",
808 Count(count),
809 Ratio(count, total),
810 Ratio(cumulative, total),
811 )
812 )
813 return rows
814
815 return Section(
816 "Pair counts",

Callers

nothing calls this directly

Calls 9

itemgetterClass · 0.90
CountClass · 0.85
get_opcode_statsMethod · 0.80
get_pair_countsMethod · 0.80
isliceMethod · 0.80
RatioClass · 0.70
itemsMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…