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

Function pair_count_section

Tools/scripts/summarize_stats.py:793–829  ·  view source on GitHub ↗
(prefix: str, title=None)

Source from the content-addressed store, hash-verified

791
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",
817 f"Pair counts for top 100 {title if title else prefix} pairs",
818 [
819 Table(
820 ("Pair", "Count:", "Self:", "Cumulative:"),
821 calc_pair_count_table,
822 )
823 ],
824 comparative=False,
825 doc="""
826 Pairs of specialized operations that deoptimize and are then followed by
827 the corresponding unspecialized instruction are not counted as pairs.
828 """,
829 )
830
831
832def pre_succ_pairs_section() -> Section:

Callers 2

iter_optimization_tablesFunction · 0.85
summarize_stats.pyFile · 0.85

Calls 2

SectionClass · 0.70
TableClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…