Bug 1425605 - Add the start/end mark names to performance.measure profiler markers; r?baku,mstange
MozReview-Commit-ID: I8DzSlSi124
--- a/dom/performance/Performance.cpp
+++ b/dom/performance/Performance.cpp
@@ -323,19 +323,32 @@ Performance::Measure(const nsAString& aN
InsertUserEntry(performanceMeasure);
#ifdef MOZ_GECKO_PROFILER
if (profiler_is_active()) {
TimeStamp startTimeStamp = CreationTimeStamp() +
TimeDuration::FromMilliseconds(startTime);
TimeStamp endTimeStamp = CreationTimeStamp() +
TimeDuration::FromMilliseconds(endTime);
+
+ // Convert to Maybe values so that Optional types do not need to be used in
+ // the profiler.
+ Maybe<nsString> startMark;
+ if (aStartMark.WasPassed()) {
+ startMark.emplace(aStartMark.Value());
+ }
+ Maybe<nsString> endMark;
+ if (aEndMark.WasPassed()) {
+ endMark.emplace(aEndMark.Value());
+ }
+
profiler_add_marker(
"UserTiming",
- MakeUnique<UserTimingMarkerPayload>(aName, startTimeStamp, endTimeStamp));
+ MakeUnique<UserTimingMarkerPayload>(aName, startMark, endMark,
+ startTimeStamp, endTimeStamp));
}
#endif
}
void
Performance::ClearMeasures(const Optional<nsAString>& aName)
{
ClearUserEntries(aName, NS_LITERAL_STRING("measure"));
--- a/tools/profiler/core/ProfilerMarkerPayload.cpp
+++ b/tools/profiler/core/ProfilerMarkerPayload.cpp
@@ -4,16 +4,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "GeckoProfiler.h"
#include "ProfilerBacktrace.h"
#include "ProfilerMarkerPayload.h"
#include "gfxASurface.h"
#include "Layers.h"
#include "mozilla/Sprintf.h"
+#include "mozilla/Maybe.h"
using namespace mozilla;
void
ProfilerMarkerPayload::StreamCommonProps(const char* aMarkerType,
SpliceableJSONWriter& aWriter,
const TimeStamp& aProcessStartTime,
UniqueStacks& aUniqueStacks)
@@ -70,16 +71,27 @@ IOMarkerPayload::StreamPayload(Spliceabl
void
UserTimingMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
const TimeStamp& aProcessStartTime,
UniqueStacks& aUniqueStacks)
{
StreamCommonProps("UserTiming", aWriter, aProcessStartTime, aUniqueStacks);
aWriter.StringProperty("name", NS_ConvertUTF16toUTF8(mName).get());
aWriter.StringProperty("entryType", mEntryType);
+
+ if (mStartMark.isSome()) {
+ aWriter.StringProperty("startMark", NS_ConvertUTF16toUTF8(mStartMark.value()).get());
+ } else {
+ aWriter.NullProperty("startMark");
+ }
+ if (mEndMark.isSome()) {
+ aWriter.StringProperty("endMark", NS_ConvertUTF16toUTF8(mEndMark.value()).get());
+ } else {
+ aWriter.NullProperty("endMark");
+ }
}
void
DOMEventMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
const TimeStamp& aProcessStartTime,
UniqueStacks& aUniqueStacks)
{
StreamCommonProps("DOMEvent", aWriter, aProcessStartTime, aUniqueStacks);
--- a/tools/profiler/public/ProfilerMarkerPayload.h
+++ b/tools/profiler/public/ProfilerMarkerPayload.h
@@ -3,16 +3,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef ProfilerMarkerPayload_h
#define ProfilerMarkerPayload_h
#include "mozilla/Attributes.h"
+#include "mozilla/Maybe.h"
#include "mozilla/RefPtr.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/UniquePtrExtensions.h"
#include "nsString.h"
#include "GeckoProfiler.h"
#include "js/Utility.h"
@@ -145,29 +146,35 @@ public:
UserTimingMarkerPayload(const nsAString& aName,
const mozilla::TimeStamp& aStartTime)
: ProfilerMarkerPayload(aStartTime, aStartTime)
, mEntryType("mark")
, mName(aName)
{}
UserTimingMarkerPayload(const nsAString& aName,
+ const mozilla::Maybe<nsString>& aStartMark,
+ const mozilla::Maybe<nsString>& aEndMark,
const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime)
: ProfilerMarkerPayload(aStartTime, aEndTime)
, mEntryType("measure")
, mName(aName)
+ , mStartMark(aStartMark)
+ , mEndMark(aEndMark)
{}
DECL_STREAM_PAYLOAD
private:
// Either "mark" or "measure".
const char* mEntryType;
nsString mName;
+ mozilla::Maybe<nsString> mStartMark;
+ mozilla::Maybe<nsString> mEndMark;
};
// Contains the translation applied to a 2d layer so we can track the layer
// position at each frame.
class LayerTranslationMarkerPayload : public ProfilerMarkerPayload
{
public:
LayerTranslationMarkerPayload(mozilla::layers::Layer* aLayer,