From af4c80b2f6253c7a2894db2710313875ec856451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Qu=C3=A8ze?= Date: Thu, 26 Oct 2023 21:06:32 +0000 Subject: [PATCH] Bug 1860896 - Output events recorded with SystemResourceMonitor.record_event as instant markers in profiles, r=glandium. Differential Revision: https://phabricator.services.mozilla.com/D191787 --- .../mozsystemmonitor/resourcemonitor.py | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py b/testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py index 71875a294cfa5..3b3732335afbc 100644 --- a/testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py +++ b/testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py @@ -972,10 +972,15 @@ def add_marker(name_index, start, end, data, precision=None): # For short duration markers, the profiler front-end may show up to # 3 digits after the decimal point (ie. µs precision). markers["startTime"].append(round((start - start_time) * 1000, precision)) - markers["endTime"].append(round((end - start_time) * 1000, precision)) + if end is None: + markers["endTime"].append(None) + # 0 = Instant marker + markers["phase"].append(0) + else: + markers["endTime"].append(round((end - start_time) * 1000, precision)) + # 1 = marker with start and end times, 2 = start but no end. + markers["phase"].append(1) markers["category"].append(0) - # 1 = marker with start and end times, 2 = start but no end. - markers["phase"].append(1) markers["name"].append(name_index) markers["data"].append(data) markers["length"] = markers["length"] + 1 @@ -1106,5 +1111,16 @@ def format_percent(value): if text: markerData["text"] = text add_marker(get_string_index(name), start, end, markerData, 3) + if self.events: + event_string_index = get_string_index("Event") + for event_time, text in self.events: + if text: + add_marker( + event_string_index, + event_time, + None, + {"type": "Text", "text": text}, + 3, + ) return profile