Close any open markers at the end of profiling.
(self)
| 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.""" |
no test coverage detected