MCPcopy Create free account
hub / github.com/python/cpython / flush_span

Method flush_span

Lib/profiling/sampling/heatmap_collector.py:1097–1117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1095 span_chars = []
1096
1097 def flush_span():
1098 nonlocal span_chars, current_range
1099 if span_chars:
1100 text = html.escape(''.join(span_chars))
1101 if current_range:
1102 data = range_data.get(current_range, {'samples': 0, 'opcodes': []})
1103 samples = data['samples']
1104 opcodes = ', '.join(data['opcodes'][:3]) # Top 3 opcodes
1105 if len(data['opcodes']) > 3:
1106 opcodes += f" +{len(data['opcodes']) - 3} more"
1107 pct = int(100 * samples / total_line_samples) if total_line_samples > 0 else 0
1108 result.append(f'<span class="instr-span" '
1109 f'data-col-start="{current_range[0]}" '
1110 f'data-col-end="{current_range[1]}" '
1111 f'data-samples="{samples}" '
1112 f'data-max-samples="{max_range_samples}" '
1113 f'data-pct="{pct}" '
1114 f'data-opcodes="{html.escape(opcodes)}">{text}</span>')
1115 else:
1116 result.append(text)
1117 span_chars = []
1118
1119 while char_idx < len(content):
1120 char = content[char_idx]

Callers

nothing calls this directly

Calls 4

escapeMethod · 0.80
joinMethod · 0.45
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected