Bug 1425605 - Add the start/end mark names to performance.measure profiler markers; r=baku,mstange

MozReview-Commit-ID: I8DzSlSi124

--HG--
extra : rebase_source : 5062bf33824284df7346dae15595f8e1e479bc40
This commit is contained in:
Greg Tatum 2018-03-08 16:36:53 -06:00
parent dc90c4a5d0
commit 4f7596f26a
3 changed files with 33 additions and 1 deletions

View File

@ -328,9 +328,22 @@ Performance::Measure(const nsAString& aName,
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
}

View File

@ -9,6 +9,7 @@
#include "gfxASurface.h"
#include "Layers.h"
#include "mozilla/Sprintf.h"
#include "mozilla/Maybe.h"
using namespace mozilla;
@ -75,6 +76,17 @@ UserTimingMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
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

View File

@ -8,6 +8,7 @@
#define ProfilerMarkerPayload_h
#include "mozilla/Attributes.h"
#include "mozilla/Maybe.h"
#include "mozilla/RefPtr.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/UniquePtrExtensions.h"
@ -150,11 +151,15 @@ public:
{}
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
@ -163,6 +168,8 @@ 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