Bug 1646266 - Profiler Markers 2.0 tests - r=gregtatum

Differential Revision: https://phabricator.services.mozilla.com/D87260
This commit is contained in:
Gerald Squelart 2020-09-02 04:03:32 +00:00
Родитель ff8b12cb5c
Коммит b1c2892ebb
2 изменённых файлов: 491 добавлений и 2 удалений

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

@ -11,6 +11,7 @@
#ifdef MOZ_GECKO_PROFILER
# include "BaseProfilerMarkerPayload.h"
# include "mozilla/BaseProfilerMarkerTypes.h"
# include "mozilla/BlocksRingBuffer.h"
# include "mozilla/leb128iterator.h"
# include "mozilla/ModuloBuffer.h"
@ -36,6 +37,7 @@
#include <algorithm>
#include <atomic>
#include <iostream>
#include <thread>
#include <type_traits>
#include <utility>
@ -3396,6 +3398,7 @@ void TestProfiler() {
static const unsigned long long fibStart = 37;
printf("Fibonacci(%llu)...\n", fibStart);
AUTO_BASE_PROFILER_LABEL("Label around Fibonacci", OTHER);
unsigned long long f = Fibonacci(fibStart);
printf("Fibonacci(%llu) = %llu\n", fibStart, f);
});
@ -3453,6 +3456,20 @@ void TestProfiler() {
baseprofiler::FileIOMarkerPayload(
"operation", "source", "filename", TimeStamp::NowUnfuzzed(),
TimeStamp::NowUnfuzzed(), std::move(cause)));
baseprofiler::AddMarker<mozilla::baseprofiler::markers::FileIO>(
"m2fileio", mozilla::baseprofiler::category::OTHER, "op2", "src2", "f2",
MarkerThreadId{});
baseprofiler::AddMarker<mozilla::baseprofiler::markers::FileIO>(
"m2fileio-capture",
mozilla::baseprofiler::category::OTHER.WithOptions(
MarkerStack::Capture()),
"op2", "src2", "f2", MarkerThreadId{});
baseprofiler::AddMarker<mozilla::baseprofiler::markers::FileIO>(
"m2fileio-take-backtrace",
mozilla::baseprofiler::category::OTHER.WithOptions(
MarkerStack::TakeBacktrace(
baseprofiler::profiler_capture_backtrace())),
"op2", "src2", "f2", MarkerThreadId{});
baseprofiler::profiler_add_marker(
"UserTimingMarkerPayload", baseprofiler::ProfilingCategoryPair::OTHER,
@ -3482,6 +3499,67 @@ void TestProfiler() {
baseprofiler::LogMarkerPayload("module", "text",
TimeStamp::NowUnfuzzed()));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
"markers 2.0 without options", mozilla::baseprofiler::category::OTHER));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
"markers 2.0 with option",
mozilla::baseprofiler::category::OTHER.WithOptions(
MarkerInnerWindowId(123))));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker<>(
"default-templated markers 2.0 without options",
mozilla::baseprofiler::category::OTHER));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker<>(
"default-templated markers 2.0 with option",
mozilla::baseprofiler::category::OTHER.WithOptions(
MarkerInnerWindowId(123))));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<::mozilla::baseprofiler::markers::NoPayload>(
"explicitly-default-templated markers 2.0 without options",
mozilla::baseprofiler::category::OTHER));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<::mozilla::baseprofiler::markers::NoPayload>(
"explicitly-default-templated markers 2.0 with option",
mozilla::baseprofiler::category::OTHER.WithOptions(
MarkerInnerWindowId(123))));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::Tracing>(
"tracing", mozilla::baseprofiler::category::OTHER, "category"));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::UserTimingMark>(
"mark", mozilla::baseprofiler::category::OTHER, "mark name"));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker<
mozilla::baseprofiler::markers::UserTimingMeasure>(
"measure", mozilla::baseprofiler::category::OTHER, "measure name",
Some(ProfilerString8View("start")), Some(ProfilerString8View("end"))));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::Hang>(
"hang", mozilla::baseprofiler::category::OTHER));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::LongTask>(
"longtask", mozilla::baseprofiler::category::OTHER));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::Text>(
"text", mozilla::baseprofiler::category::OTHER, "text text"));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::Log>(
"log", mozilla::baseprofiler::category::OTHER, "module", "text"));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::MediaSample>(
"media sample", mozilla::baseprofiler::category::OTHER, 123, 456));
printf("Sleep 1s...\n");
{
AUTO_BASE_PROFILER_THREAD_SLEEP;
@ -3537,6 +3615,252 @@ void TestProfiler() {
printf("TestProfiler done\n");
}
void StreamMarkers(const mozilla::ProfileChunkedBuffer& aBuffer,
mozilla::JSONWriter& aWriter) {
aWriter.Start();
{
aWriter.StartArrayProperty("data");
{
aBuffer.ReadEach([&](mozilla::ProfileBufferEntryReader& aEntryReader) {
mozilla::ProfileBufferEntryKind entryKind =
aEntryReader.ReadObject<mozilla::ProfileBufferEntryKind>();
MOZ_RELEASE_ASSERT(entryKind ==
mozilla::ProfileBufferEntryKind::Marker);
const bool success = mozilla::base_profiler_markers_detail::
DeserializeAfterKindAndStream(
aEntryReader, aWriter, 0,
[&](const mozilla::ProfilerString8View& aName) {
aWriter.StringElement(aName.String().c_str());
},
[&](mozilla::ProfileChunkedBuffer&) {
aWriter.StringElement("Real backtrace would be here");
});
MOZ_RELEASE_ASSERT(success);
});
}
aWriter.EndArray();
}
aWriter.End();
}
void PrintMarkers(const mozilla::ProfileChunkedBuffer& aBuffer) {
mozilla::baseprofiler::SpliceableJSONWriter writer(
mozilla::MakeUnique<mozilla::baseprofiler::OStreamJSONWriteFunc>(
std::cout));
StreamMarkers(aBuffer, writer);
}
void TestMarkerNoPayload() {
printf("TestMarkerNoPayload...\n");
mozilla::ProfileBufferChunkManagerSingle chunkManager(512);
mozilla::ProfileChunkedBuffer buffer(
mozilla::ProfileChunkedBuffer::ThreadSafety::WithoutMutex, chunkManager);
mozilla::ProfileBufferBlockIndex i0 =
mozilla::baseprofiler::AddMarkerToBuffer<>(
buffer, "literal", mozilla::baseprofiler::category::OTHER_Profiling);
MOZ_RELEASE_ASSERT(i0);
const std::string dynamic = "dynamic";
mozilla::ProfileBufferBlockIndex i1 =
mozilla::baseprofiler::AddMarkerToBuffer<>(
buffer, dynamic,
mozilla::baseprofiler::category::GRAPHICS_FlushingAsyncPaints);
MOZ_RELEASE_ASSERT(i1);
MOZ_RELEASE_ASSERT(i1 > i0);
mozilla::ProfileBufferBlockIndex i2 =
mozilla::baseprofiler::AddMarkerToBuffer<>(
buffer, std::string_view("string_view"),
mozilla::baseprofiler::category::GRAPHICS_FlushingAsyncPaints);
MOZ_RELEASE_ASSERT(i2);
MOZ_RELEASE_ASSERT(i2 > i1);
# ifdef DEBUG
buffer.Dump();
# endif
PrintMarkers(buffer);
printf("TestMarkerNoPayload done\n");
}
void TestUserMarker() {
printf("TestUserMarker...\n");
// User-defined marker type with text. If there are no `Convert` functions,
// it's fine to define it right in the function where it's used.
struct MarkerTypeTestMinimal {
static constexpr const char* MarkerTypeName() { return "test-minimal"; }
static void StreamJSONMarkerData(mozilla::JSONWriter& aWriter,
const std::string& aText) {
aWriter.StringProperty("text", aText.c_str());
}
};
mozilla::ProfileBufferChunkManagerSingle chunkManager(1024);
mozilla::ProfileChunkedBuffer buffer(
mozilla::ProfileChunkedBuffer::ThreadSafety::WithoutMutex, chunkManager);
MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
std::string("payload text")));
MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2",
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
mozilla::MarkerThreadId(123)),
std::string("ThreadId(123)")));
auto start = mozilla::TimeStamp::NowUnfuzzed();
MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2",
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
mozilla::MarkerTiming::InstantAt(start)),
std::string("InstantAt(start)")));
auto then = mozilla::TimeStamp::NowUnfuzzed();
MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2",
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
mozilla::MarkerTiming::IntervalStart(start)),
std::string("IntervalStart(start)")));
MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2",
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
mozilla::MarkerTiming::IntervalEnd(then)),
std::string("IntervalEnd(then)")));
MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2",
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
mozilla::MarkerTiming::Interval(start, then)),
std::string("Interval(start, then)")));
MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2",
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
mozilla::MarkerTiming::IntervalUntilNowFrom(start)),
std::string("IntervalUntilNowFrom(start)")));
MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2",
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
mozilla::MarkerStack::NoStack()),
std::string("NoStack")));
// Note: We cannot test stack-capture here, because the profiler is not
// initialized.
MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2",
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
mozilla::MarkerInnerWindowId(123)),
std::string("InnerWindowId(123)")));
# ifdef DEBUG
buffer.Dump();
# endif
PrintMarkers(buffer);
printf("TestUserMarker done\n");
}
void TestPredefinedMarkers() {
printf("TestPredefinedMarkers...\n");
// User-defined marker type with text. If there are no `Convert` functions,
// it's fine to define it right in the function where it's used.
struct MarkerTypeTestMinimal {
static constexpr const char* MarkerTypeName() { return "test-minimal"; }
static void StreamJSONMarkerData(mozilla::JSONWriter& aWriter,
const std::string& aText) {
aWriter.StringProperty("text", aText.c_str());
}
};
mozilla::ProfileBufferChunkManagerSingle chunkManager(1024);
mozilla::ProfileChunkedBuffer buffer(
mozilla::ProfileChunkedBuffer::ThreadSafety::WithoutMutex, chunkManager);
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::Tracing>(
buffer, std::string_view("tracing"),
mozilla::baseprofiler::category::OTHER, "category"));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::UserTimingMark>(
buffer, std::string_view("mark"), mozilla::baseprofiler::category::OTHER,
"mark name"));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::UserTimingMeasure>(
buffer, std::string_view("measure"),
mozilla::baseprofiler::category::OTHER, "measure name ",
mozilla::Some(mozilla::ProfilerString8View(" start ")),
mozilla::Some(mozilla::ProfilerString8View("end"))));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::Hang>(
buffer, std::string_view("hang"),
mozilla::baseprofiler::category::OTHER));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::LongTask>(
buffer, std::string_view("long task"),
mozilla::baseprofiler::category::OTHER));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::Text>(
buffer, std::string_view("text"), mozilla::baseprofiler::category::OTHER,
"text text"));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::Log>(
buffer, std::string_view("log"), mozilla::baseprofiler::category::OTHER,
"module", "text"));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::MediaSample>(
buffer, std::string_view("media"), mozilla::baseprofiler::category::OTHER,
123, 456));
# ifdef DEBUG
buffer.Dump();
# endif
PrintMarkers(buffer);
printf("TestPredefinedMarkers done\n");
}
void TestProfilerMarkers() {
printf("TestProfilerMarkers -- pid: %d, tid: %d\n",
mozilla::baseprofiler::profiler_current_process_id(),
mozilla::baseprofiler::profiler_current_thread_id());
// ::SleepMilli(10000);
TestMarkerNoPayload();
TestUserMarker();
TestPredefinedMarkers();
printf("TestProfilerMarkers done\n");
}
#else // MOZ_GECKO_PROFILER
// Testing that macros are still #defined (but do nothing) when
@ -3544,14 +3868,50 @@ void TestProfiler() {
void TestProfiler() {
// These don't need to make sense, we just want to know that they're defined
// and don't do anything.
# ifndef AUTO_BASE_PROFILER_INIT
# error AUTO_BASE_PROFILER_INIT not #defined
# endif // AUTO_BASE_PROFILER_INIT
AUTO_BASE_PROFILER_INIT;
// This wouldn't build if the macro did output its arguments.
# ifndef AUTO_BASE_PROFILER_TEXT_MARKER_CAUSE
# error AUTO_BASE_PROFILER_TEXT_MARKER_CAUSE not #defined
# endif // AUTO_BASE_PROFILER_TEXT_MARKER_CAUSE
AUTO_BASE_PROFILER_TEXT_MARKER_CAUSE(catch, catch, catch, catch);
# ifndef AUTO_BASE_PROFILER_LABEL
# error AUTO_BASE_PROFILER_LABEL not #defined
# endif // AUTO_BASE_PROFILER_LABEL
AUTO_BASE_PROFILER_LABEL(catch, catch);
# ifndef AUTO_BASE_PROFILER_THREAD_SLEEP
# error AUTO_BASE_PROFILER_THREAD_SLEEP not #defined
# endif // AUTO_BASE_PROFILER_THREAD_SLEEP
AUTO_BASE_PROFILER_THREAD_SLEEP;
# ifndef BASE_PROFILER_MARKER_UNTYPED
# error BASE_PROFILER_MARKER_UNTYPED not #defined
# endif // BASE_PROFILER_MARKER_UNTYPED
BASE_PROFILER_MARKER_UNTYPED(catch, catch);
# ifndef BASE_PROFILER_MARKER
# error BASE_PROFILER_MARKER not #defined
# endif // BASE_PROFILER_MARKER
BASE_PROFILER_MARKER(catch, catch, catch);
BASE_PROFILER_MARKER(catch, catch, catch, catch);
# ifndef BASE_PROFILER_MARKER_TEXT
# error BASE_PROFILER_MARKER_TEXT not #defined
# endif // BASE_PROFILER_MARKER_TEXT
BASE_PROFILER_MARKER_TEXT(catch, catch, catch);
}
// Testing that macros are still #defined (but do nothing) when
// MOZ_GECKO_PROFILER is disabled.
void TestProfilerMarkers() {
// These don't need to make sense, we just want to know that they're defined
// and don't do anything.
}
#endif // MOZ_GECKO_PROFILER else
@ -3569,9 +3929,10 @@ int main()
// ::SleepMilli(10000);
#endif // MOZ_GECKO_PROFILER
// Note that there are two `TestProfiler` functions above, depending on
// whether MOZ_GECKO_PROFILER is #defined.
// Note that there are two `TestProfiler{,Markers}` functions above, depending
// on whether MOZ_GECKO_PROFILER is #defined.
TestProfiler();
TestProfilerMarkers();
return 0;
}

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

@ -10,6 +10,7 @@
// profiler internals.
#include "GeckoProfiler.h"
#include "mozilla/ProfilerMarkerTypes.h"
#include "platform.h"
#include "ProfileBuffer.h"
#include "ProfilerMarkerPayload.h"
@ -542,6 +543,9 @@ TEST(GeckoProfiler, Pause)
PROFILER_ADD_MARKER("Paused", OTHER);
info2 = profiler_get_buffer_info();
ASSERT_TRUE(info1->mRangeEnd == info2->mRangeEnd);
PROFILER_MARKER_UNTYPED("Paused v2", OTHER);
Maybe<ProfilerBufferInfo> info3 = profiler_get_buffer_info();
ASSERT_TRUE(info2->mRangeEnd == info3->mRangeEnd);
profiler_resume();
@ -697,6 +701,22 @@ TEST(GeckoProfiler, Markers)
ASSERT_EQ(longstrCut[kMax - 1], 'c');
longstrCut[kMax - 1] = '\0';
// Test basic markers 2.0.
MOZ_RELEASE_ASSERT(
profiler_add_marker<>("default-templated markers 2.0 with empty options",
geckoprofiler::category::OTHER));
PROFILER_MARKER_UNTYPED("default-templated markers 2.0 with option",
OTHER.WithOptions(MarkerStack::TakeBacktrace(
profiler_capture_backtrace())));
PROFILER_MARKER("explicitly-default-templated markers 2.0 with empty options",
OTHER, NoPayload);
MOZ_RELEASE_ASSERT(profiler_add_marker<::geckoprofiler::markers::NoPayload>(
"explicitly-default-templated markers 2.0 with option",
geckoprofiler::category::OTHER));
// Used in markers below.
TimeStamp ts1 = TimeStamp::NowUnfuzzed();
@ -717,16 +737,32 @@ TEST(GeckoProfiler, Markers)
"FileIOMarkerPayload marker", OTHER, FileIOMarkerPayload,
("operation", "source", "filename", ts1, ts2, nullptr));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::FileIO>(
"FileIOMarkerPayload marker 2.0",
geckoprofiler::category::OTHER.WithOptions(
MarkerTiming::Interval(ts1, ts2)),
"operation", "source", "filename", MarkerThreadId{}));
PROFILER_ADD_MARKER_WITH_PAYLOAD(
"FileIOMarkerPayload marker off-MT", OTHER, FileIOMarkerPayload,
("operation2", "source2", "filename2", ts1, ts2, nullptr, Some(123)));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::FileIO>(
"FileIOMarkerPayload marker 2.0 off-MT",
geckoprofiler::category::OTHER.WithOptions(
MarkerTiming::Interval(ts1, ts2)),
"operation2", "source2", "filename2", MarkerThreadId{123}));
// Other markers in alphabetical order of payload class names.
PROFILER_ADD_MARKER_WITH_PAYLOAD(
"DOMEventMarkerPayload marker", OTHER, DOMEventMarkerPayload,
(u"dom event"_ns, ts1, "category", TRACING_EVENT, mozilla::Nothing()));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::DOMEvent>(
"DOMEventMarkerPayload marker 2.0", geckoprofiler::category::OTHER,
u"dom event"_ns, ts1, "category"));
{
const char gcMajorJSON[] = "42";
const auto len = strlen(gcMajorJSON);
@ -829,6 +865,41 @@ TEST(GeckoProfiler, Markers)
mozilla::ipc::MessageDirection::eSending,
mozilla::ipc::MessagePhase::Endpoint, false, ts1));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Tracing>(
"Tracing", geckoprofiler::category::OTHER, "category"));
MOZ_RELEASE_ASSERT(
profiler_add_marker<geckoprofiler::markers::UserTimingMark>(
"UserTimingMark", geckoprofiler::category::OTHER, "mark name"));
MOZ_RELEASE_ASSERT(
profiler_add_marker<geckoprofiler::markers::UserTimingMeasure>(
"UserTimingMeasure", geckoprofiler::category::OTHER, "measure name",
Some(mozilla::ProfilerString8View("start")),
Some(mozilla::ProfilerString8View("end"))));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Hang>(
"Hang", geckoprofiler::category::OTHER));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::LongTask>(
"LongTask", geckoprofiler::category::OTHER));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Text>(
"Text", geckoprofiler::category::OTHER, "Text text"));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Log>(
"Log", geckoprofiler::category::OTHER, "module", "log text"));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::MediaSample>(
"MediaSample", geckoprofiler::category::OTHER, 123, 456));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Budget>(
"Budget", geckoprofiler::category::OTHER));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::DOMEvent>(
"DOMEvent", geckoprofiler::category::OTHER, u"event"_ns, ts2,
"category"));
SpliceableChunkedJSONWriter w;
w.Start();
EXPECT_TRUE(::profiler_stream_json_for_this_process(w));
@ -867,9 +938,16 @@ TEST(GeckoProfiler, Markers)
S_M5_gtest7,
S_M5_gtest8,
S_M5_gtest9,
S_Markers2DefaultEmptyOptions,
S_Markers2DefaultWithOptions,
S_Markers2ExplicitDefaultEmptyOptions,
S_Markers2ExplicitDefaultWithOptions,
S_FileIOMarkerPayload,
S_FileIOMarker2,
S_FileIOMarkerPayloadOffMT,
S_FileIOMarker2OffMT,
S_DOMEventMarkerPayload,
S_DOMEventMarker2,
S_GCMajorMarkerPayload,
S_GCMinorMarkerPayload,
S_GCSliceMarkerPayload,
@ -1074,6 +1152,24 @@ TEST(GeckoProfiler, Markers)
} else if (nameString == "M3") {
ASSERT_EQ(state, S_M3);
state = State(state + 1);
} else if (nameString ==
"default-templated markers 2.0 with empty options") {
EXPECT_EQ(state, S_Markers2DefaultEmptyOptions);
state = State(S_Markers2DefaultEmptyOptions + 1);
} else if (nameString ==
"default-templated markers 2.0 with option") {
EXPECT_EQ(state, S_Markers2DefaultWithOptions);
state = State(S_Markers2DefaultWithOptions + 1);
} else if (nameString ==
"explicitly-default-templated markers 2.0 with empty "
"options") {
EXPECT_EQ(state, S_Markers2ExplicitDefaultEmptyOptions);
state = State(S_Markers2ExplicitDefaultEmptyOptions + 1);
} else if (nameString ==
"explicitly-default-templated markers 2.0 with "
"option") {
EXPECT_EQ(state, S_Markers2ExplicitDefaultWithOptions);
state = State(S_Markers2ExplicitDefaultWithOptions + 1);
}
} else {
// root.threads[0].markers.data[i] is an array with 6 elements,
@ -1207,6 +1303,17 @@ TEST(GeckoProfiler, Markers)
EXPECT_EQ_JSON(payload["filename"], String, "filename");
EXPECT_FALSE(payload.isMember("threadId"));
} else if (nameString == "FileIOMarkerPayload marker 2.0") {
EXPECT_EQ(state, S_FileIOMarker2);
state = State(S_FileIOMarker2 + 1);
EXPECT_EQ(typeString, "FileIO");
EXPECT_TIMING_INTERVAL_AT(ts1Double, ts2Double);
EXPECT_TRUE(payload["stack"].isNull());
EXPECT_EQ_JSON(payload["operation"], String, "operation");
EXPECT_EQ_JSON(payload["source"], String, "source");
EXPECT_EQ_JSON(payload["filename"], String, "filename");
EXPECT_FALSE(payload.isMember("threadId"));
} else if (nameString == "FileIOMarkerPayload marker off-MT") {
EXPECT_EQ(state, S_FileIOMarkerPayloadOffMT);
state = State(S_FileIOMarkerPayloadOffMT + 1);
@ -1218,6 +1325,18 @@ TEST(GeckoProfiler, Markers)
EXPECT_EQ_JSON(payload["filename"], String, "filename2");
EXPECT_EQ_JSON(payload["threadId"], Int, 123);
} else if (nameString ==
"FileIOMarkerPayload marker 2.0 off-MT") {
EXPECT_EQ(state, S_FileIOMarker2OffMT);
state = State(S_FileIOMarker2OffMT + 1);
EXPECT_EQ(typeString, "FileIO");
EXPECT_TIMING_INTERVAL_AT(ts1Double, ts2Double);
EXPECT_TRUE(payload["stack"].isNull());
EXPECT_EQ_JSON(payload["operation"], String, "operation2");
EXPECT_EQ_JSON(payload["source"], String, "source2");
EXPECT_EQ_JSON(payload["filename"], String, "filename2");
EXPECT_EQ_JSON(payload["threadId"], Int, 123);
} else if (nameString == "DOMEventMarkerPayload marker") {
EXPECT_EQ(state, S_DOMEventMarkerPayload);
state = State(S_DOMEventMarkerPayload + 1);
@ -1228,6 +1347,15 @@ TEST(GeckoProfiler, Markers)
EXPECT_EQ_JSON(payload["timeStamp"], Double, ts1Double);
EXPECT_EQ_JSON(payload["eventType"], String, "dom event");
} else if (nameString == "DOMEventMarkerPayload marker 2.0") {
EXPECT_EQ(state, S_DOMEventMarker2);
state = State(S_DOMEventMarker2 + 1);
EXPECT_EQ(typeString, "tracing");
EXPECT_TRUE(payload["stack"].isNull());
EXPECT_EQ_JSON(payload["category"], String, "category");
EXPECT_EQ_JSON(payload["timeStamp"], Double, ts1Double);
EXPECT_EQ_JSON(payload["eventType"], String, "dom event");
} else if (nameString == "GCMajorMarkerPayload marker") {
EXPECT_EQ(state, S_GCMajorMarkerPayload);
state = State(S_GCMajorMarkerPayload + 1);