Skip to content

Commit 095722b

Browse files
authored
Exporting start_time in InstructionEvent to Inspector (#10295)
Differential Revision: D72740782 Pull Request resolved: #10344
1 parent 9e64882 commit 095722b

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

devtools/inspector/_inspector.py

+15
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ class Event:
334334
_delegate_time_scale_converter: Optional[
335335
Callable[[Union[int, str], Union[int, float]], Union[int, float]]
336336
] = None
337+
_start_time: Optional[List[Union[int, float]]] = None
337338

338339
@cached_property
339340
def delegate_debug_metadatas(self) -> Union[List[str], Dict[str, Any]]:
@@ -352,6 +353,13 @@ def raw_delegate_debug_metadatas(self) -> List[str]:
352353
"""
353354
return self._delegate_debug_metadatas
354355

356+
@property
357+
def start_time(self) -> Optional[List[Union[int, float]]]:
358+
"""
359+
Returns the start time of the event.
360+
"""
361+
return self._start_time
362+
355363
def to_dataframe(self, _units="") -> pd.DataFrame:
356364
"""
357365
Convert the Event into a pandas DataFrame
@@ -402,6 +410,7 @@ def truncated_list(long_list: List[str]) -> str:
402410
"is_delegated_op": self.is_delegated_op,
403411
"delegate_backend_name": self.delegate_backend_name,
404412
"debug_data": [self.debug_data],
413+
"start_time": [self._start_time],
405414
}
406415

407416
@staticmethod
@@ -530,6 +539,7 @@ def _populate_profiling_related_fields(
530539

531540
# Fill out fields from profile event
532541
data = []
542+
stime = []
533543
delegate_debug_metadatas = []
534544
for event in events:
535545
if (profile_events := event.profile_events) is not None:
@@ -571,6 +581,7 @@ def _populate_profiling_related_fields(
571581
)
572582

573583
data.append(scaled_time)
584+
stime.append(profile_event.start_time)
574585
delegate_debug_metadatas.append(
575586
profile_event.delegate_debug_metadata
576587
if profile_event.delegate_debug_metadata
@@ -583,6 +594,10 @@ def _populate_profiling_related_fields(
583594
if any(delegate_debug_metadatas):
584595
ret_event._delegate_debug_metadatas = delegate_debug_metadatas
585596

597+
# add _start_time to the event
598+
if len(stime) > 0:
599+
ret_event._start_time = stime
600+
586601
@staticmethod
587602
def _populate_debugging_related_fields(
588603
ret_event: "Event",

devtools/inspector/tests/event_blocks_test.py

+1
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ def _test_profile_event_generation(
518518
delegate_debug_metadatas if is_delegated else []
519519
),
520520
_instruction_id=event_signature.instruction_id,
521+
_start_time=[0, 0, 0],
521522
)
522523
self.assertEqual(event, expected_event)
523524

0 commit comments

Comments
 (0)