Bug 1807011 - Do not call TimeStamp::Now for text markers when profiler is not running r=julienw

Differential Revision: https://phabricator.services.mozilla.com/D166804
This commit is contained in:
Nazım Can Altınova 2023-01-18 10:56:18 +00:00
Родитель 114a9dd6fc
Коммит 3894ab42c2
2 изменённых файлов: 19 добавлений и 13 удалений

Просмотреть файл

@ -203,16 +203,19 @@ class MOZ_RAII AutoProfilerTextMarker {
mText(aText) { mText(aText) {
MOZ_ASSERT(mOptions.Timing().EndTime().IsNull(), MOZ_ASSERT(mOptions.Timing().EndTime().IsNull(),
"AutoProfilerTextMarker options shouldn't have an end time"); "AutoProfilerTextMarker options shouldn't have an end time");
if (mOptions.Timing().StartTime().IsNull()) { if (profiler_is_active_and_unpaused() &&
mOptions.Timing().StartTime().IsNull()) {
mOptions.Set(MarkerTiming::InstantNow()); mOptions.Set(MarkerTiming::InstantNow());
} }
} }
~AutoProfilerTextMarker() { ~AutoProfilerTextMarker() {
mOptions.TimingRef().SetIntervalEnd(); if (profiler_is_active_and_unpaused()) {
AUTO_PROFILER_STATS(AUTO_BASE_PROFILER_MARKER_TEXT); mOptions.TimingRef().SetIntervalEnd();
AddMarker(ProfilerString8View::WrapNullTerminatedString(mMarkerName), AUTO_PROFILER_STATS(AUTO_BASE_PROFILER_MARKER_TEXT);
mCategory, std::move(mOptions), markers::TextMarker{}, mText); AddMarker(ProfilerString8View::WrapNullTerminatedString(mMarkerName),
mCategory, std::move(mOptions), markers::TextMarker{}, mText);
}
} }
protected: protected:

Просмотреть файл

@ -216,19 +216,22 @@ class MOZ_RAII AutoProfilerTextMarker {
mText(aText) { mText(aText) {
MOZ_ASSERT(mOptions.Timing().EndTime().IsNull(), MOZ_ASSERT(mOptions.Timing().EndTime().IsNull(),
"AutoProfilerTextMarker options shouldn't have an end time"); "AutoProfilerTextMarker options shouldn't have an end time");
if (mOptions.Timing().StartTime().IsNull()) { if (profiler_is_active_and_unpaused() &&
mOptions.Timing().StartTime().IsNull()) {
mOptions.Set(mozilla::MarkerTiming::InstantNow()); mOptions.Set(mozilla::MarkerTiming::InstantNow());
} }
} }
~AutoProfilerTextMarker() { ~AutoProfilerTextMarker() {
AUTO_PROFILER_LABEL("TextMarker", PROFILER); if (profiler_is_active_and_unpaused()) {
mOptions.TimingRef().SetIntervalEnd(); AUTO_PROFILER_LABEL("TextMarker", PROFILER);
AUTO_PROFILER_STATS(AUTO_PROFILER_MARKER_TEXT); mOptions.TimingRef().SetIntervalEnd();
profiler_add_marker( AUTO_PROFILER_STATS(AUTO_PROFILER_MARKER_TEXT);
mozilla::ProfilerString8View::WrapNullTerminatedString(mMarkerName), profiler_add_marker(
mCategory, std::move(mOptions), geckoprofiler::markers::TextMarker{}, mozilla::ProfilerString8View::WrapNullTerminatedString(mMarkerName),
mText); mCategory, std::move(mOptions), geckoprofiler::markers::TextMarker{},
mText);
}
} }
protected: protected: