mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 04:09:50 +00:00
Bug 1774329 - Output profiling logs in the most compact json - r=florian
Differential Revision: https://phabricator.services.mozilla.com/D152606
This commit is contained in:
parent
159d4fe860
commit
515c9f0788
@ -370,6 +370,19 @@ static constexpr uint32_t StartupExtraDefaultFeatures() {
|
||||
return ProfilerFeature::FileIOAll | ProfilerFeature::IPCMessages;
|
||||
}
|
||||
|
||||
Json::String ToCompactString(const Json::Value& aJsonValue) {
|
||||
Json::StreamWriterBuilder builder;
|
||||
// No indentations, and no newlines.
|
||||
builder["indentation"] = "";
|
||||
// This removes spaces after colons.
|
||||
builder["enableYAMLCompatibility"] = false;
|
||||
// Only 6 digits after the decimal point; timestamps in ms have ns precision.
|
||||
builder["precision"] = 6;
|
||||
builder["precisionType"] = "decimal";
|
||||
|
||||
return Json::writeString(builder, aJsonValue);
|
||||
}
|
||||
|
||||
/* static */ mozilla::baseprofiler::detail::BaseProfilerMutex
|
||||
ProfilingLog::gMutex;
|
||||
/* static */ mozilla::UniquePtr<Json::Value> ProfilingLog::gLog;
|
||||
@ -3343,7 +3356,7 @@ static void locked_profiler_stream_json_for_this_process(
|
||||
{
|
||||
nsAutoCString pid;
|
||||
pid.AppendInt(int64_t(profiler_current_process_id().ToNumber()));
|
||||
Json::String logString = aProfilingLogObject.toStyledString();
|
||||
Json::String logString = ToCompactString(aProfilingLogObject);
|
||||
aWriter.SplicedJSONProperty(pid, logString);
|
||||
}
|
||||
aWriter.EndObject();
|
||||
|
@ -75,6 +75,11 @@ extern mozilla::LazyLogModule gProfilerLog;
|
||||
|
||||
typedef uint8_t* Address;
|
||||
|
||||
// Stringify the given JSON value, in the most compact format.
|
||||
// Note: Numbers are limited to a precision of 6 decimal digits, so that
|
||||
// timestamps in ms have a precision in ns.
|
||||
Json::String ToCompactString(const Json::Value& aJsonValue);
|
||||
|
||||
// Profiling log stored in a Json::Value. The actual log only exists while the
|
||||
// profiler is running, and will be inserted at the end of the JSON profile.
|
||||
class ProfilingLog {
|
||||
|
@ -1364,7 +1364,7 @@ void nsProfiler::FinishGathering() {
|
||||
{
|
||||
nsAutoCString pid;
|
||||
pid.AppendInt(int64_t(profiler_current_process_id().ToNumber()));
|
||||
Json::String logString = mGatheringLog->toStyledString();
|
||||
Json::String logString = ToCompactString(*mGatheringLog);
|
||||
mGatheringLog = nullptr;
|
||||
mWriter->SplicedJSONProperty(pid, logString);
|
||||
}
|
||||
|
@ -1288,7 +1288,7 @@ void JSONWhitespaceCheck(const char* aOutput) {
|
||||
}
|
||||
}
|
||||
|
||||
EXPECT_LE(double(whitespaces) / double(length), 0.125);
|
||||
EXPECT_LE(double(whitespaces) / double(length), 0.1);
|
||||
}
|
||||
|
||||
// Does the GETTER return a non-null TYPE? (Non-critical)
|
||||
|
Loading…
x
Reference in New Issue
Block a user