mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1675409 - Migrated UserTimingMarkerPayload to Markers 2.0 API - r=gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D96051
This commit is contained in:
parent
bfc0fb9f6d
commit
8ed348d0c7
@ -216,6 +216,53 @@ void Performance::ClearUserEntries(const Optional<nsAString>& aEntryName,
|
||||
|
||||
void Performance::ClearResourceTimings() { mResourceEntries.Clear(); }
|
||||
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
struct UserTimingMarker {
|
||||
static constexpr Span<const char> MarkerTypeName() {
|
||||
return MakeStringSpan("UserTiming");
|
||||
}
|
||||
static void StreamJSONMarkerData(
|
||||
baseprofiler::SpliceableJSONWriter& aWriter,
|
||||
const ProfilerString16View& aName, bool aIsMeasure,
|
||||
const Maybe<ProfilerString16View>& aStartMark,
|
||||
const Maybe<ProfilerString16View>& aEndMark) {
|
||||
aWriter.StringProperty("name", NS_ConvertUTF16toUTF8(aName.Data()));
|
||||
if (aIsMeasure) {
|
||||
aWriter.StringProperty("entryType", "measure");
|
||||
} else {
|
||||
aWriter.StringProperty("entryType", "mark");
|
||||
}
|
||||
|
||||
if (aStartMark.isSome()) {
|
||||
aWriter.StringProperty("startMark",
|
||||
NS_ConvertUTF16toUTF8(aStartMark->Data()));
|
||||
} else {
|
||||
aWriter.NullProperty("startMark");
|
||||
}
|
||||
if (aEndMark.isSome()) {
|
||||
aWriter.StringProperty("endMark",
|
||||
NS_ConvertUTF16toUTF8(aEndMark->Data()));
|
||||
} else {
|
||||
aWriter.NullProperty("endMark");
|
||||
}
|
||||
}
|
||||
static MarkerSchema MarkerTypeDisplay() {
|
||||
using MS = MarkerSchema;
|
||||
MS schema{MS::Location::markerChart, MS::Location::markerTable};
|
||||
schema.SetAllLabels("{marker.data.name}");
|
||||
schema.AddStaticLabelValue("Marker", "UserTiming");
|
||||
schema.AddKeyLabelFormat("entryType", "Entry Type", MS::Format::string);
|
||||
schema.AddKeyLabelFormat("name", "Name", MS::Format::string);
|
||||
schema.AddKeyLabelFormat("startMark", "Start Mark", MS::Format::string);
|
||||
schema.AddKeyLabelFormat("endMark", "End Mark", MS::Format::string);
|
||||
schema.AddStaticLabelValue("Description",
|
||||
"UserTimingMeasure is created using the DOM API "
|
||||
"performance.measure().");
|
||||
return schema;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
void Performance::Mark(const nsAString& aName, ErrorResult& aRv) {
|
||||
// We add nothing when 'privacy.resistFingerprinting' is on.
|
||||
if (nsContentUtils::ShouldResistFingerprinting()) {
|
||||
@ -237,8 +284,9 @@ void Performance::Mark(const nsAString& aName, ErrorResult& aRv) {
|
||||
if (GetOwner()) {
|
||||
innerWindowId = Some(GetOwner()->WindowID());
|
||||
}
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD("UserTiming", DOM, UserTimingMarkerPayload,
|
||||
(aName, TimeStamp::Now(), innerWindowId));
|
||||
profiler_add_marker("UserTiming", geckoprofiler::category::DOM,
|
||||
MarkerInnerWindowId(innerWindowId), UserTimingMarker{},
|
||||
aName, /* aIsMeasure */ false, Nothing{}, Nothing{});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -332,9 +380,11 @@ void Performance::Measure(const nsAString& aName,
|
||||
if (GetOwner()) {
|
||||
innerWindowId = Some(GetOwner()->WindowID());
|
||||
}
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD("UserTiming", DOM, UserTimingMarkerPayload,
|
||||
(aName, startMark, endMark, startTimeStamp,
|
||||
endTimeStamp, innerWindowId));
|
||||
profiler_add_marker("UserTiming", geckoprofiler::category::DOM,
|
||||
{MarkerTiming::Interval(startTimeStamp, endTimeStamp),
|
||||
MarkerInnerWindowId(innerWindowId)},
|
||||
UserTimingMarker{}, aName, /* aIsMeasure */ true,
|
||||
startMark, endMark);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -48,69 +48,6 @@ struct Tracing {
|
||||
}
|
||||
};
|
||||
|
||||
struct UserTimingMark {
|
||||
static constexpr Span<const char> MarkerTypeName() {
|
||||
return MakeStringSpan("UserTimingMark");
|
||||
}
|
||||
static void StreamJSONMarkerData(SpliceableJSONWriter& aWriter,
|
||||
const ProfilerString8View& aName) {
|
||||
aWriter.StringProperty("name", aName);
|
||||
aWriter.StringProperty("entryType", "mark");
|
||||
aWriter.NullProperty("startMark");
|
||||
aWriter.NullProperty("endMark");
|
||||
}
|
||||
static MarkerSchema MarkerTypeDisplay() {
|
||||
using MS = MarkerSchema;
|
||||
MS schema{MS::Location::markerChart, MS::Location::markerTable};
|
||||
schema.SetAllLabels("{marker.data.name}");
|
||||
schema.AddStaticLabelValue("Marker", "UserTiming");
|
||||
schema.AddKeyLabelFormat("entryType", "Entry Type", MS::Format::string);
|
||||
schema.AddKeyLabelFormat("name", "Name", MS::Format::string);
|
||||
schema.AddStaticLabelValue(
|
||||
"Description",
|
||||
"UserTimingMark is created using the DOM API performance.mark().");
|
||||
return schema;
|
||||
}
|
||||
};
|
||||
|
||||
struct UserTimingMeasure {
|
||||
static constexpr Span<const char> MarkerTypeName() {
|
||||
return MakeStringSpan("UserTimingMeasure");
|
||||
}
|
||||
static void StreamJSONMarkerData(SpliceableJSONWriter& aWriter,
|
||||
const ProfilerString8View& aName,
|
||||
const Maybe<ProfilerString8View>& aStartMark,
|
||||
const Maybe<ProfilerString8View>& aEndMark) {
|
||||
aWriter.StringProperty("name", aName);
|
||||
aWriter.StringProperty("entryType", "measure");
|
||||
|
||||
if (aStartMark.isSome()) {
|
||||
aWriter.StringProperty("startMark", *aStartMark);
|
||||
} else {
|
||||
aWriter.NullProperty("startMark");
|
||||
}
|
||||
if (aEndMark.isSome()) {
|
||||
aWriter.StringProperty("endMark", *aEndMark);
|
||||
} else {
|
||||
aWriter.NullProperty("endMark");
|
||||
}
|
||||
}
|
||||
static MarkerSchema MarkerTypeDisplay() {
|
||||
using MS = MarkerSchema;
|
||||
MS schema{MS::Location::markerChart, MS::Location::markerTable};
|
||||
schema.SetAllLabels("{marker.data.name}");
|
||||
schema.AddStaticLabelValue("Marker", "UserTiming");
|
||||
schema.AddKeyLabelFormat("entryType", "Entry Type", MS::Format::string);
|
||||
schema.AddKeyLabelFormat("name", "Name", MS::Format::string);
|
||||
schema.AddKeyLabelFormat("startMark", "Start Mark", MS::Format::string);
|
||||
schema.AddKeyLabelFormat("endMark", "End Mark", MS::Format::string);
|
||||
schema.AddStaticLabelValue("Description",
|
||||
"UserTimingMeasure is created using the DOM API "
|
||||
"performance.measure().");
|
||||
return schema;
|
||||
}
|
||||
};
|
||||
|
||||
struct MediaSampleMarker {
|
||||
static constexpr Span<const char> MarkerTypeName() {
|
||||
return MakeStringSpan("MediaSample");
|
||||
|
@ -3470,15 +3470,6 @@ void TestProfiler() {
|
||||
"tracing", mozilla::baseprofiler::category::OTHER, {},
|
||||
mozilla::baseprofiler::markers::Tracing{}, "category"));
|
||||
|
||||
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
|
||||
"mark", mozilla::baseprofiler::category::OTHER, {},
|
||||
mozilla::baseprofiler::markers::UserTimingMark{}, "mark name"));
|
||||
|
||||
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
|
||||
"measure", mozilla::baseprofiler::category::OTHER, {},
|
||||
mozilla::baseprofiler::markers::UserTimingMeasure{}, "measure name",
|
||||
Some(ProfilerString8View("start")), Some(ProfilerString8View("end"))));
|
||||
|
||||
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
|
||||
"text", mozilla::baseprofiler::category::OTHER, {},
|
||||
mozilla::baseprofiler::markers::Text{}, "text text"));
|
||||
@ -3541,10 +3532,6 @@ void TestProfiler() {
|
||||
MOZ_RELEASE_ASSERT(profileSV.find("\"markerSchema\": [") != svnpos);
|
||||
MOZ_RELEASE_ASSERT(profileSV.find("\"name\": \"Text\",") != svnpos);
|
||||
MOZ_RELEASE_ASSERT(profileSV.find("\"name\": \"tracing\",") != svnpos);
|
||||
MOZ_RELEASE_ASSERT(profileSV.find("\"name\": \"UserTimingMark\",") !=
|
||||
svnpos);
|
||||
MOZ_RELEASE_ASSERT(profileSV.find("\"name\": \"UserTimingMeasure\",") !=
|
||||
svnpos);
|
||||
MOZ_RELEASE_ASSERT(profileSV.find("\"name\": \"MediaSample\",") != svnpos);
|
||||
MOZ_RELEASE_ASSERT(profileSV.find("\"display\": [") != svnpos);
|
||||
MOZ_RELEASE_ASSERT(profileSV.find("\"marker-chart\"") != svnpos);
|
||||
@ -4048,17 +4035,6 @@ void TestPredefinedMarkers() {
|
||||
mozilla::baseprofiler::category::OTHER, {},
|
||||
mozilla::baseprofiler::markers::Tracing{}, "category"));
|
||||
|
||||
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
|
||||
buffer, std::string_view("mark"), mozilla::baseprofiler::category::OTHER,
|
||||
{}, mozilla::baseprofiler::markers::UserTimingMark{}, "mark name"));
|
||||
|
||||
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
|
||||
buffer, std::string_view("measure"),
|
||||
mozilla::baseprofiler::category::OTHER, {},
|
||||
mozilla::baseprofiler::markers::UserTimingMeasure{}, "measure name ",
|
||||
mozilla::Some(mozilla::ProfilerString8View(" start ")),
|
||||
mozilla::Some(mozilla::ProfilerString8View("end"))));
|
||||
|
||||
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
|
||||
buffer, std::string_view("text"), mozilla::baseprofiler::category::OTHER,
|
||||
{}, mozilla::baseprofiler::markers::Text{}, "text text"));
|
||||
|
@ -32,8 +32,6 @@ namespace geckoprofiler::markers {
|
||||
|
||||
// Import some common markers from mozilla::baseprofiler::markers.
|
||||
using Tracing = mozilla::baseprofiler::markers::Tracing;
|
||||
using UserTimingMark = mozilla::baseprofiler::markers::UserTimingMark;
|
||||
using UserTimingMeasure = mozilla::baseprofiler::markers::UserTimingMeasure;
|
||||
using MediaSampleMarker = mozilla::baseprofiler::markers::MediaSampleMarker;
|
||||
using ContentBuildMarker = mozilla::baseprofiler::markers::ContentBuildMarker;
|
||||
|
||||
|
@ -835,15 +835,6 @@ TEST(GeckoProfiler, Markers)
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD("TextMarkerPayload marker 2", OTHER,
|
||||
TextMarkerPayload, ("text"_ns, ts1, ts2));
|
||||
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD("UserTimingMarkerPayload marker mark", OTHER,
|
||||
UserTimingMarkerPayload,
|
||||
(u"mark name"_ns, ts1, mozilla::Nothing()));
|
||||
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD(
|
||||
"UserTimingMarkerPayload marker measure", OTHER, UserTimingMarkerPayload,
|
||||
(u"measure name"_ns, Some(u"start mark"_ns), Some(u"end mark"_ns), ts1,
|
||||
ts2, mozilla::Nothing()));
|
||||
|
||||
MOZ_RELEASE_ASSERT(profiler_add_marker(
|
||||
"Text in main thread with stack", geckoprofiler::category::OTHER,
|
||||
MarkerStack::Capture(), geckoprofiler::markers::Text{}, ""));
|
||||
@ -887,16 +878,6 @@ TEST(GeckoProfiler, Markers)
|
||||
profiler_add_marker("Tracing", geckoprofiler::category::OTHER, {},
|
||||
geckoprofiler::markers::Tracing{}, "category"));
|
||||
|
||||
MOZ_RELEASE_ASSERT(profiler_add_marker(
|
||||
"UserTimingMark", geckoprofiler::category::OTHER, {},
|
||||
geckoprofiler::markers::UserTimingMark{}, "mark name"));
|
||||
|
||||
MOZ_RELEASE_ASSERT(profiler_add_marker(
|
||||
"UserTimingMeasure", geckoprofiler::category::OTHER, {},
|
||||
geckoprofiler::markers::UserTimingMeasure{}, "measure name",
|
||||
Some(mozilla::ProfilerString8View("start")),
|
||||
Some(mozilla::ProfilerString8View("end"))));
|
||||
|
||||
MOZ_RELEASE_ASSERT(profiler_add_marker("Text", geckoprofiler::category::OTHER,
|
||||
{}, geckoprofiler::markers::Text{},
|
||||
"Text text"));
|
||||
@ -953,8 +934,6 @@ TEST(GeckoProfiler, Markers)
|
||||
S_NetworkMarkerPayload_redirect,
|
||||
S_TextMarkerPayload1,
|
||||
S_TextMarkerPayload2,
|
||||
S_UserTimingMarkerPayload_mark,
|
||||
S_UserTimingMarkerPayload_measure,
|
||||
S_TextWithStack,
|
||||
S_TextToMTWithStack,
|
||||
S_RegThread_TextToMTWithStack,
|
||||
@ -1356,27 +1335,6 @@ TEST(GeckoProfiler, Markers)
|
||||
EXPECT_TRUE(payload["stack"].isNull());
|
||||
EXPECT_EQ_JSON(payload["name"], String, "text");
|
||||
|
||||
} else if (nameString == "UserTimingMarkerPayload marker mark") {
|
||||
EXPECT_EQ(state, S_UserTimingMarkerPayload_mark);
|
||||
state = State(S_UserTimingMarkerPayload_mark + 1);
|
||||
EXPECT_EQ(typeString, "UserTiming");
|
||||
EXPECT_TIMING_INSTANT_AT(ts1Double);
|
||||
EXPECT_TRUE(payload["stack"].isNull());
|
||||
EXPECT_EQ_JSON(payload["name"], String, "mark name");
|
||||
EXPECT_EQ_JSON(payload["entryType"], String, "mark");
|
||||
|
||||
} else if (nameString ==
|
||||
"UserTimingMarkerPayload marker measure") {
|
||||
EXPECT_EQ(state, S_UserTimingMarkerPayload_measure);
|
||||
state = State(S_UserTimingMarkerPayload_measure + 1);
|
||||
EXPECT_EQ(typeString, "UserTiming");
|
||||
EXPECT_TIMING_INTERVAL_AT(ts1Double, ts2Double);
|
||||
EXPECT_TRUE(payload["stack"].isNull());
|
||||
EXPECT_EQ_JSON(payload["name"], String, "measure name");
|
||||
EXPECT_EQ_JSON(payload["entryType"], String, "measure");
|
||||
EXPECT_EQ_JSON(payload["startMark"], String, "start mark");
|
||||
EXPECT_EQ_JSON(payload["endMark"], String, "end mark");
|
||||
|
||||
} else if (nameString == "Text in main thread with stack") {
|
||||
EXPECT_EQ(state, S_TextWithStack);
|
||||
state = State(S_TextWithStack + 1);
|
||||
@ -1494,70 +1452,6 @@ TEST(GeckoProfiler, Markers)
|
||||
EXPECT_EQ_JSON(data[0u]["label"], String, "Type");
|
||||
EXPECT_EQ_JSON(data[0u]["format"], String, "string");
|
||||
|
||||
} else if (nameString == "UserTimingMark") {
|
||||
EXPECT_EQ(display.size(), 2u);
|
||||
EXPECT_EQ(display[0u].asString(), "marker-chart");
|
||||
EXPECT_EQ(display[1u].asString(), "marker-table");
|
||||
|
||||
ASSERT_EQ(data.size(), 4u);
|
||||
|
||||
ASSERT_TRUE(data[0u].isObject());
|
||||
EXPECT_EQ_JSON(data[0u]["label"], String, "Marker");
|
||||
EXPECT_EQ_JSON(data[0u]["value"], String, "UserTiming");
|
||||
|
||||
ASSERT_TRUE(data[1u].isObject());
|
||||
EXPECT_EQ_JSON(data[1u]["key"], String, "entryType");
|
||||
EXPECT_EQ_JSON(data[1u]["label"], String, "Entry Type");
|
||||
EXPECT_EQ_JSON(data[1u]["format"], String, "string");
|
||||
|
||||
ASSERT_TRUE(data[2u].isObject());
|
||||
EXPECT_EQ_JSON(data[2u]["key"], String, "name");
|
||||
EXPECT_EQ_JSON(data[2u]["label"], String, "Name");
|
||||
EXPECT_EQ_JSON(data[2u]["format"], String, "string");
|
||||
|
||||
ASSERT_TRUE(data[3u].isObject());
|
||||
EXPECT_EQ_JSON(data[3u]["label"], String, "Description");
|
||||
EXPECT_EQ_JSON(data[3u]["value"], String,
|
||||
"UserTimingMark is created using the DOM API "
|
||||
"performance.mark().");
|
||||
|
||||
} else if (nameString == "UserTimingMeasure") {
|
||||
EXPECT_EQ(display.size(), 2u);
|
||||
EXPECT_EQ(display[0u].asString(), "marker-chart");
|
||||
EXPECT_EQ(display[1u].asString(), "marker-table");
|
||||
|
||||
ASSERT_EQ(data.size(), 6u);
|
||||
|
||||
ASSERT_TRUE(data[0u].isObject());
|
||||
EXPECT_EQ_JSON(data[0u]["label"], String, "Marker");
|
||||
EXPECT_EQ_JSON(data[0u]["value"], String, "UserTiming");
|
||||
|
||||
ASSERT_TRUE(data[1u].isObject());
|
||||
EXPECT_EQ_JSON(data[1u]["key"], String, "entryType");
|
||||
EXPECT_EQ_JSON(data[1u]["label"], String, "Entry Type");
|
||||
EXPECT_EQ_JSON(data[1u]["format"], String, "string");
|
||||
|
||||
ASSERT_TRUE(data[2u].isObject());
|
||||
EXPECT_EQ_JSON(data[2u]["key"], String, "name");
|
||||
EXPECT_EQ_JSON(data[2u]["label"], String, "Name");
|
||||
EXPECT_EQ_JSON(data[2u]["format"], String, "string");
|
||||
|
||||
ASSERT_TRUE(data[3u].isObject());
|
||||
EXPECT_EQ_JSON(data[3u]["key"], String, "startMark");
|
||||
EXPECT_EQ_JSON(data[3u]["label"], String, "Start Mark");
|
||||
EXPECT_EQ_JSON(data[3u]["format"], String, "string");
|
||||
|
||||
ASSERT_TRUE(data[4u].isObject());
|
||||
EXPECT_EQ_JSON(data[4u]["key"], String, "endMark");
|
||||
EXPECT_EQ_JSON(data[4u]["label"], String, "End Mark");
|
||||
EXPECT_EQ_JSON(data[4u]["format"], String, "string");
|
||||
|
||||
ASSERT_TRUE(data[5u].isObject());
|
||||
EXPECT_EQ_JSON(data[5u]["label"], String, "Description");
|
||||
EXPECT_EQ_JSON(data[5u]["value"], String,
|
||||
"UserTimingMeasure is created using the DOM API "
|
||||
"performance.measure().");
|
||||
|
||||
} else if (nameString == "BHR-detected hang") {
|
||||
EXPECT_EQ(display.size(), 3u);
|
||||
EXPECT_EQ(display[0u].asString(), "marker-chart");
|
||||
@ -1627,10 +1521,6 @@ TEST(GeckoProfiler, Markers)
|
||||
// Check that we've got all expected schema.
|
||||
EXPECT_TRUE(testedSchemaNames.find("Text") != testedSchemaNames.end());
|
||||
EXPECT_TRUE(testedSchemaNames.find("tracing") != testedSchemaNames.end());
|
||||
EXPECT_TRUE(testedSchemaNames.find("UserTimingMark") !=
|
||||
testedSchemaNames.end());
|
||||
EXPECT_TRUE(testedSchemaNames.find("UserTimingMeasure") !=
|
||||
testedSchemaNames.end());
|
||||
EXPECT_TRUE(testedSchemaNames.find("MediaSample") !=
|
||||
testedSchemaNames.end());
|
||||
} // markerSchema
|
||||
|
Loading…
Reference in New Issue
Block a user