diff --git a/toolkit/components/glean/ipc/FOGIPC.cpp b/toolkit/components/glean/ipc/FOGIPC.cpp index 1cdc643e3dcc8..25bb5dd6a2f06 100644 --- a/toolkit/components/glean/ipc/FOGIPC.cpp +++ b/toolkit/components/glean/ipc/FOGIPC.cpp @@ -41,8 +41,34 @@ using mozilla::ipc::UtilityProcessManager; using mozilla::ipc::UtilityProcessParent; using FlushFOGDataPromise = mozilla::dom::ContentParent::FlushFOGDataPromise; -namespace mozilla { -namespace glean { +namespace geckoprofiler::markers { + +using namespace mozilla; + +struct ProcessingTimeMarker { + static constexpr Span MarkerTypeName() { + return MakeStringSpan("ProcessingTime"); + } + static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter, + int64_t aDiffMs, + const ProfilerString8View& aType) { + aWriter.IntProperty("time", aDiffMs); + aWriter.StringProperty("label", aType); + } + static MarkerSchema MarkerTypeDisplay() { + using MS = MarkerSchema; + MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable}; + schema.AddKeyLabelFormat("time", "Recorded Time", MS::Format::Milliseconds); + schema.SetTooltipLabel("{marker.name} - {marker.data.label}"); + schema.SetTableLabel( + "{marker.name} - {marker.data.label}: {marker.data.time}"); + return schema; + } +}; + +} // namespace geckoprofiler::markers + +namespace mozilla::glean { void RecordPowerMetrics() { static uint64_t previousCpuTime = 0, previousGpuTime = 0; @@ -116,6 +142,8 @@ void RecordPowerMetrics() { } power::total_cpu_time_ms.Add(nNewCpuTime); power::cpu_time_per_process_type_ms.Get(type).Add(nNewCpuTime); + PROFILER_MARKER("CPU Time", OTHER, {}, ProcessingTimeMarker, nNewCpuTime, + type); previousCpuTime += newCpuTime; } @@ -126,6 +154,8 @@ void RecordPowerMetrics() { } power::total_gpu_time_ms.Add(nNewGpuTime); power::gpu_time_per_process_type_ms.Get(type).Add(nNewGpuTime); + PROFILER_MARKER("GPU Time", OTHER, {}, ProcessingTimeMarker, nNewGpuTime, + type); previousGpuTime += newGpuTime; } } @@ -341,5 +371,4 @@ void TestTriggerMetrics(uint32_t aProcessType, } } -} // namespace glean -} // namespace mozilla +} // namespace mozilla::glean