summaryrefslogtreecommitdiffstats
path: root/dom/performance/Performance.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:29 +0000
commit59203c63bb777a3bacec32fb8830fba33540e809 (patch)
tree58298e711c0ff0575818c30485b44a2f21bf28a0 /dom/performance/Performance.cpp
parentAdding upstream version 126.0.1. (diff)
downloadfirefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz
firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/performance/Performance.cpp')
-rw-r--r--dom/performance/Performance.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/dom/performance/Performance.cpp b/dom/performance/Performance.cpp
index ce2557100d..070bca9ec4 100644
--- a/dom/performance/Performance.cpp
+++ b/dom/performance/Performance.cpp
@@ -33,6 +33,7 @@
#include "mozilla/dom/PerformanceObserverBinding.h"
#include "mozilla/dom/PerformanceNavigationTiming.h"
#include "mozilla/IntegerPrintfMacros.h"
+#include "mozilla/Perfetto.h"
#include "mozilla/Preferences.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/dom/WorkerPrivate.h"
@@ -764,6 +765,25 @@ already_AddRefed<PerformanceMeasure> Performance::Measure(
detail.setNull();
}
+#ifdef MOZ_PERFETTO
+ // Perfetto requires that events are properly nested within each category.
+ // Since this is not a guarantee here, we need to define a dynamic category
+ // for each measurement so it's not prematurely ended by another measurement
+ // that overlaps. We also use the usertiming category to guard these markers
+ // so it's easy to toggle.
+ if (TRACE_EVENT_CATEGORY_ENABLED("usertiming")) {
+ NS_ConvertUTF16toUTF8 str(aName);
+ perfetto::DynamicCategory category{str.get()};
+ TimeStamp startTimeStamp =
+ CreationTimeStamp() + TimeDuration::FromMilliseconds(startTime);
+ TimeStamp endTimeStamp =
+ CreationTimeStamp() + TimeDuration::FromMilliseconds(endTime);
+ PERFETTO_TRACE_EVENT_BEGIN(category, perfetto::DynamicString{str.get()},
+ startTimeStamp);
+ PERFETTO_TRACE_EVENT_END(category, endTimeStamp);
+ }
+#endif
+
RefPtr<PerformanceMeasure> performanceMeasure = new PerformanceMeasure(
GetParentObject(), aName, startTime, endTime, detail);
InsertUserEntry(performanceMeasure);