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

Method _finalize_markers

Lib/profiling/sampling/gecko_collector.py:630–657  ·  view source on GitHub ↗

Close any open markers at the end of profiling.

(self)

Source from the content-addressed store, hash-verified

628 return frame_idx
629
630 def _finalize_markers(self):
631 """Close any open markers at the end of profiling."""
632 end_time = self.last_sample_time
633
634 # Close all open markers for each thread using a generic approach
635 marker_states = [
636 (self.has_gil_start, "Has GIL", CATEGORY_GIL),
637 (self.no_gil_start, "No GIL", CATEGORY_GIL),
638 (self.on_cpu_start, "On CPU", CATEGORY_CPU),
639 (self.off_cpu_start, "Off CPU", CATEGORY_CPU),
640 (self.python_code_start, "Python Code", CATEGORY_CODE_TYPE),
641 (self.native_code_start, "Native Code", CATEGORY_CODE_TYPE),
642 (self.gil_wait_start, "Waiting for GIL", CATEGORY_GIL),
643 (self.gc_start_per_thread, "GC Collecting", CATEGORY_GC),
644 (self.exception_start, "Has Exception", CATEGORY_EXCEPTION),
645 (self.no_exception_start, "No Exception", CATEGORY_EXCEPTION),
646 ]
647
648 for state_dict, marker_name, category in marker_states:
649 for tid in list(state_dict.keys()):
650 self._add_marker(tid, marker_name, state_dict[tid], end_time, category)
651 del state_dict[tid]
652
653 # Close any open opcode markers
654 for tid, state in list(self.opcode_state.items()):
655 opcode, lineno, col_offset, funcname, filename, start_time = state
656 self._add_opcode_interval_marker(tid, opcode, lineno, col_offset, funcname, start_time, end_time)
657 self.opcode_state.clear()
658
659 def export(self, filename):
660 """Export the profile to a Gecko JSON file."""

Callers 1

exportMethod · 0.95

Calls 6

_add_markerMethod · 0.95
listClass · 0.85
keysMethod · 0.45
itemsMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected