Skip to content

Commit 50f63d0

Browse files
committed
Make bytecode spacer
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
1 parent b13b6f0 commit 50f63d0

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

Lib/profiling/sampling/_heatmap_assets/heatmap.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,13 @@
12001200
transform: rotate(90deg);
12011201
}
12021202

1203+
.bytecode-spacer {
1204+
flex-shrink: 0;
1205+
width: 20px;
1206+
height: 20px;
1207+
margin: 0 4px;
1208+
}
1209+
12031210
.bytecode-panel {
12041211
margin-left: 90px;
12051212
padding: 8px 15px;

Lib/profiling/sampling/heatmap_collector.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,9 @@ def __init__(self, *args, **kwargs):
477477
self._path_info = get_python_path_info()
478478
self.stats = {}
479479

480+
# Opcode collection flag
481+
self.opcodes_enabled = False
482+
480483
# Template loader (loads all templates once)
481484
self._template_loader = _TemplateLoader()
482485

@@ -528,6 +531,8 @@ def process_frames(self, frames, thread_id):
528531
self._record_line_sample(filename, lineno, funcname, is_leaf=(i == 0))
529532

530533
if opcode is not None:
534+
# Set opcodes_enabled flag when we first encounter opcode data
535+
self.opcodes_enabled = True
531536
self._record_bytecode_sample(filename, lineno, opcode,
532537
end_lineno, col_offset, end_col_offset)
533538

@@ -953,6 +958,9 @@ def _build_line_html(self, line_num: int, line_content: str,
953958
f'onclick="toggleBytecode(this)" title="Show bytecode">&#9654;</button>'
954959
)
955960
bytecode_panel_html = f' <div class="bytecode-panel" id="bytecode-{line_num}" style="display:none;"></div>\n'
961+
elif self.opcodes_enabled:
962+
# Add invisible spacer to maintain consistent indentation when opcodes are enabled
963+
bytecode_btn_html = '<div class="bytecode-spacer"></div>'
956964

957965
# Get navigation buttons
958966
nav_buttons_html = self._build_navigation_buttons(filename, line_num)

0 commit comments

Comments
 (0)