Bug 1462784 - Add the list of categories into the profile JSON and bump the version to 11. r?njn
MozReview-Commit-ID: 1g4WqsWFFbg
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -1555,22 +1555,62 @@ StreamTaskTracer(PSLockRef aLock, Splice
aWriter.EndArray();
aWriter.DoubleProperty(
"start", static_cast<double>(tasktracer::GetStartTime()));
#endif
}
static void
+StreamCategories(SpliceableJSONWriter& aWriter)
+{
+ // Same order as ProfilingStackFrame::Category.
+ // The list of available color names is:
+ // transparent, grey, purple, yellow, orange, lightblue, green, blue, magenta
+ aWriter.Start();
+ aWriter.StringProperty("name", "Idle");
+ aWriter.StringProperty("color", "transparent");
+ aWriter.EndObject();
+ aWriter.Start();
+ aWriter.StringProperty("name", "Other");
+ aWriter.StringProperty("color", "grey");
+ aWriter.EndObject();
+ aWriter.Start();
+ aWriter.StringProperty("name", "Layout");
+ aWriter.StringProperty("color", "purple");
+ aWriter.EndObject();
+ aWriter.Start();
+ aWriter.StringProperty("name", "JavaScript");
+ aWriter.StringProperty("color", "yellow");
+ aWriter.EndObject();
+ aWriter.Start();
+ aWriter.StringProperty("name", "GC / CC");
+ aWriter.StringProperty("color", "orange");
+ aWriter.EndObject();
+ aWriter.Start();
+ aWriter.StringProperty("name", "Network");
+ aWriter.StringProperty("color", "lightblue");
+ aWriter.EndObject();
+ aWriter.Start();
+ aWriter.StringProperty("name", "Graphics");
+ aWriter.StringProperty("color", "green");
+ aWriter.EndObject();
+ aWriter.Start();
+ aWriter.StringProperty("name", "DOM");
+ aWriter.StringProperty("color", "blue");
+ aWriter.EndObject();
+}
+
+static void
StreamMetaJSCustomObject(PSLockRef aLock, SpliceableJSONWriter& aWriter,
bool aIsShuttingDown)
{
MOZ_RELEASE_ASSERT(CorePS::Exists() && ActivePS::Exists(aLock));
- aWriter.IntProperty("version", 10);
+ aWriter.IntProperty("version", 11);
// The "startTime" field holds the number of milliseconds since midnight
// January 1, 1970 GMT. This grotty code computes (Now - (Now -
// ProcessStartTime)) to convert CorePS::ProcessStartTime() into that form.
TimeDuration delta = TimeStamp::Now() - CorePS::ProcessStartTime();
aWriter.DoubleProperty(
"startTime", static_cast<double>(PR_Now()/1000.0 - delta.ToMilliseconds()));
@@ -1578,16 +1618,20 @@ StreamMetaJSCustomObject(PSLockRef aLock
// absolute time stamp: It's relative to startTime. This is consistent with
// all other (non-"startTime") times anywhere in the profile JSON.
if (aIsShuttingDown) {
aWriter.DoubleProperty("shutdownTime", profiler_time());
} else {
aWriter.NullProperty("shutdownTime");
}
+ aWriter.StartArrayProperty("categories");
+ StreamCategories(aWriter);
+ aWriter.EndArray();
+
if (!NS_IsMainThread()) {
// Leave the rest of the properties out if we're not on the main thread.
// At the moment, the only case in which this function is called on a
// background thread is if we're in a content process and are going to
// send this profile to the parent process. In that case, the parent
// process profile's "meta" object already has the rest of the properties,
// and the parent process profile is dumped on that process's main thread.
return;