зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1408279 - Make profile JSON easier to read. r=mstange.
Currently the choices of SingleLineStyle and MultiLineStyle are sub-optimal, which makes debugging of profiles difficult. - A large chunk of the profile is put on a single line, which is very hard to read in a text editor. - Other short and repetitive constructs are unnecessarily spread across multiple lines. This patch makes things more readable.
This commit is contained in:
Родитель
0f14d33483
Коммит
f0d3349d01
|
@ -87,7 +87,8 @@ public:
|
|||
: mWriter(aWriter)
|
||||
, mIndex(0)
|
||||
{
|
||||
aWriter.StartObjectProperty("schema");
|
||||
aWriter.StartObjectProperty("schema",
|
||||
SpliceableJSONWriter::SingleLineStyle);
|
||||
}
|
||||
|
||||
void WriteField(const char* aName) {
|
||||
|
@ -187,7 +188,7 @@ public:
|
|||
, mStrings(&aStrings)
|
||||
, mNextFreeIndex(0)
|
||||
{
|
||||
mJSONWriter.StartArrayElement();
|
||||
mJSONWriter.StartArrayElement(SpliceableJSONWriter::SingleLineStyle);
|
||||
}
|
||||
|
||||
// If you don't have access to a UniqueStrings, you had better not try and
|
||||
|
@ -197,7 +198,7 @@ public:
|
|||
, mStrings(nullptr)
|
||||
, mNextFreeIndex(0)
|
||||
{
|
||||
mJSONWriter.StartArrayElement();
|
||||
mJSONWriter.StartArrayElement(SpliceableJSONWriter::SingleLineStyle);
|
||||
}
|
||||
|
||||
~AutoArraySchemaWriter() {
|
||||
|
@ -938,7 +939,7 @@ static void
|
|||
AddPausedRange(SpliceableJSONWriter& aWriter, const char* aReason,
|
||||
const Maybe<double>& aStartTime, const Maybe<double>& aEndTime)
|
||||
{
|
||||
aWriter.Start(SpliceableJSONWriter::SingleLineStyle);
|
||||
aWriter.Start();
|
||||
if (aStartTime) {
|
||||
aWriter.DoubleProperty("startTime", *aStartTime);
|
||||
} else {
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
: JSONWriter(mozilla::Move(aWriter))
|
||||
{ }
|
||||
|
||||
void StartBareList(CollectionStyle aStyle = SingleLineStyle) {
|
||||
void StartBareList(CollectionStyle aStyle = MultiLineStyle) {
|
||||
StartCollection(nullptr, "", aStyle);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
// if have location data
|
||||
// b.NameValue(marker, "location", ...);
|
||||
if (mPayload) {
|
||||
aWriter.StartObjectElement();
|
||||
aWriter.StartObjectElement(SpliceableJSONWriter::SingleLineStyle);
|
||||
{
|
||||
mPayload->StreamPayload(aWriter, aProcessStartTime, aUniqueStacks);
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ ThreadInfo::StreamJSON(const ProfileBuffer& aBuffer,
|
|||
|
||||
double firstSampleTime = 0.0;
|
||||
|
||||
aWriter.Start(SpliceableJSONWriter::SingleLineStyle);
|
||||
aWriter.Start();
|
||||
{
|
||||
StreamSamplesAndMarkers(Name(), ThreadId(), aBuffer, aWriter,
|
||||
aProcessStartTime,
|
||||
|
|
|
@ -1670,8 +1670,7 @@ locked_profiler_stream_json_for_this_process(PSLockRef aLock,
|
|||
}
|
||||
aWriter.EndArray();
|
||||
|
||||
aWriter.StartArrayProperty("pausedRanges",
|
||||
SpliceableJSONWriter::SingleLineStyle);
|
||||
aWriter.StartArrayProperty("pausedRanges");
|
||||
{
|
||||
buffer.StreamPausedRangesToJSON(aWriter, aSinceTime);
|
||||
}
|
||||
|
@ -2449,7 +2448,7 @@ profiler_get_profile(double aSinceTime, bool aIsShuttingDown)
|
|||
MOZ_RELEASE_ASSERT(CorePS::Exists());
|
||||
|
||||
SpliceableChunkedJSONWriter b;
|
||||
b.Start(SpliceableJSONWriter::SingleLineStyle);
|
||||
b.Start();
|
||||
{
|
||||
if (!profiler_stream_json_for_this_process(b, aSinceTime,
|
||||
aIsShuttingDown)) {
|
||||
|
@ -2571,7 +2570,7 @@ locked_profiler_save_profile_to_file(PSLockRef aLock, const char* aFilename,
|
|||
stream.open(aFilename);
|
||||
if (stream.is_open()) {
|
||||
SpliceableJSONWriter w(MakeUnique<OStreamJSONWriteFunc>(stream));
|
||||
w.Start(SpliceableJSONWriter::SingleLineStyle);
|
||||
w.Start();
|
||||
{
|
||||
locked_profiler_stream_json_for_this_process(aLock, w, /* sinceTime */ 0,
|
||||
aIsShuttingDown);
|
||||
|
|
|
@ -591,7 +591,7 @@ nsProfiler::StartGathering(double aSinceTime)
|
|||
TimeStamp thisProcessFirstSampleTime;
|
||||
|
||||
// Start building up the JSON result and grab the profile from this process.
|
||||
mWriter->Start(SpliceableJSONWriter::SingleLineStyle);
|
||||
mWriter->Start();
|
||||
if (!profiler_stream_json_for_this_process(*mWriter, aSinceTime,
|
||||
/* aIsShuttingDown */ true,
|
||||
&thisProcessFirstSampleTime)) {
|
||||
|
|
|
@ -628,7 +628,7 @@ TEST(GeckoProfiler, StreamJSONForThisProcess)
|
|||
profiler_start(PROFILER_DEFAULT_ENTRIES, PROFILER_DEFAULT_INTERVAL,
|
||||
features, filters, MOZ_ARRAY_LENGTH(filters));
|
||||
|
||||
w.Start(SpliceableJSONWriter::SingleLineStyle);
|
||||
w.Start();
|
||||
ASSERT_TRUE(profiler_stream_json_for_this_process(w));
|
||||
w.End();
|
||||
|
||||
|
@ -663,7 +663,7 @@ TEST(GeckoProfiler, StreamJSONForThisProcessThreaded)
|
|||
NS_NewRunnableFunction(
|
||||
"GeckoProfiler_StreamJSONForThisProcessThreaded_Test::TestBody",
|
||||
[&]() {
|
||||
w.Start(SpliceableJSONWriter::SingleLineStyle);
|
||||
w.Start();
|
||||
ASSERT_TRUE(profiler_stream_json_for_this_process(w));
|
||||
w.End();
|
||||
}),
|
||||
|
|
Загрузка…
Ссылка в новой задаче