Commit 71e390fa authored by alph's avatar alph Committed by Commit bot

[profiler] Update cpu profile tracing format.

Encapsulate nodes and samples into cpuProfile object.

BUG=chromium:406277

Review-Url: https://chromiumcodereview.appspot.com/2425093002
Cr-Commit-Position: refs/heads/master@{#40447}
parent 99023682
......@@ -412,7 +412,7 @@ CpuProfile::CpuProfile(CpuProfiler* profiler, const char* title,
value->SetDouble("startTime",
(start_time_ - base::TimeTicks()).InMicroseconds());
TRACE_EVENT_SAMPLE_WITH_ID1(TRACE_DISABLED_BY_DEFAULT("v8.cpu_profiler"),
"CpuProfile", this, "data", std::move(value));
"Profile", this, "data", std::move(value));
}
void CpuProfile::AddPath(base::TimeTicks timestamp,
......@@ -466,6 +466,8 @@ void CpuProfile::StreamPendingTraceEvents() {
if (pending_nodes.empty() && !samples_.length()) return;
auto value = TracedValue::Create();
if (!pending_nodes.empty() || streaming_next_sample_ != samples_.length()) {
value->BeginDictionary("cpuProfile");
if (!pending_nodes.empty()) {
value->BeginArray("nodes");
for (auto node : pending_nodes) {
......@@ -475,13 +477,16 @@ void CpuProfile::StreamPendingTraceEvents() {
}
value->EndArray();
}
if (streaming_next_sample_ != samples_.length()) {
value->BeginArray("samples");
for (int i = streaming_next_sample_; i < samples_.length(); ++i) {
value->AppendInteger(samples_[i]->id());
}
value->EndArray();
}
value->EndDictionary();
}
if (streaming_next_sample_ != samples_.length()) {
value->BeginArray("timeDeltas");
base::TimeTicks lastTimestamp =
streaming_next_sample_ ? timestamps_[streaming_next_sample_ - 1]
......@@ -497,8 +502,7 @@ void CpuProfile::StreamPendingTraceEvents() {
}
TRACE_EVENT_SAMPLE_WITH_ID1(TRACE_DISABLED_BY_DEFAULT("v8.cpu_profiler"),
"CpuProfileChunk", this, "data",
std::move(value));
"ProfileChunk", this, "data", std::move(value));
}
void CpuProfile::FinishProfile() {
......@@ -507,8 +511,7 @@ void CpuProfile::FinishProfile() {
auto value = TracedValue::Create();
value->SetDouble("endTime", (end_time_ - base::TimeTicks()).InMicroseconds());
TRACE_EVENT_SAMPLE_WITH_ID1(TRACE_DISABLED_BY_DEFAULT("v8.cpu_profiler"),
"CpuProfileChunk", this, "data",
std::move(value));
"ProfileChunk", this, "data", std::move(value));
}
void CpuProfile::Print() {
......
......@@ -2111,8 +2111,8 @@ namespace {
class CpuProfileEventChecker : public v8::platform::tracing::TraceWriter {
public:
void AppendTraceEvent(TraceObject* trace_event) override {
if (trace_event->name() != std::string("CpuProfile") &&
trace_event->name() != std::string("CpuProfileChunk"))
if (trace_event->name() != std::string("Profile") &&
trace_event->name() != std::string("ProfileChunk"))
return;
CHECK(!profile_id_ || trace_event->id() == profile_id_);
CHECK_EQ(1, trace_event->num_args());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment