Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(713)

Unified Diff: src/libplatform/tracing/trace-writer.cc

Issue 2137013006: [Tracing] V8 Tracing Controller (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add Setters for TraceConfig categories Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/libplatform/tracing/trace-writer.h ('k') | src/libplatform/tracing/tracing-controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/libplatform/tracing/trace-writer.cc
diff --git a/src/libplatform/tracing/trace-writer.cc b/src/libplatform/tracing/trace-writer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..464b5713fc2b69b6076f43b7cd40ef0ad7e8dd50
--- /dev/null
+++ b/src/libplatform/tracing/trace-writer.cc
@@ -0,0 +1,57 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/libplatform/tracing/trace-writer.h"
+
+#include "src/base/platform/platform.h"
+
+namespace v8 {
+namespace platform {
+namespace tracing {
+
+JSONTraceWriter::JSONTraceWriter(std::ostream& stream) : stream_(stream) {
+ stream_ << "{\"traceEvents\":[";
+}
+
+JSONTraceWriter::~JSONTraceWriter() { stream_ << "]}"; }
+
+void JSONTraceWriter::AppendTraceEvent(TraceObject* trace_event) {
+ if (append_comma_) stream_ << ",";
+ append_comma_ = true;
+ if (trace_event->scope() == NULL) {
+ stream_ << "{\"pid\":" << trace_event->pid()
+ << ",\"tid\":" << trace_event->tid()
+ << ",\"ts\":" << trace_event->ts()
+ << ",\"tts\":" << trace_event->tts() << ",\"ph\":\""
+ << trace_event->phase() << "\",\"cat\":\""
+ << TracingController::GetCategoryGroupName(
+ trace_event->category_enabled_flag())
+ << "\",\"name\":\"" << trace_event->name()
+ << "\",\"args\":{},\"dur\":" << trace_event->duration()
+ << ",\"tdur\":" << trace_event->cpu_duration() << "}";
+ } else {
+ stream_ << "{\"pid\":" << trace_event->pid()
+ << ",\"tid\":" << trace_event->tid()
+ << ",\"ts\":" << trace_event->ts()
+ << ",\"tts\":" << trace_event->tts() << ",\"ph\":\""
+ << trace_event->phase() << "\",\"cat\":\""
+ << TracingController::GetCategoryGroupName(
+ trace_event->category_enabled_flag())
+ << "\",\"name\":\"" << trace_event->name() << "\",\"scope\":\""
+ << trace_event->scope()
+ << "\",\"args\":{},\"dur\":" << trace_event->duration()
+ << ",\"tdur\":" << trace_event->cpu_duration() << "}";
+ }
+ // TODO(fmeawad): Add support for Flow Events.
+}
+
+void JSONTraceWriter::Flush() {}
+
+TraceWriter* TraceWriter::CreateJSONTraceWriter(std::ostream& stream) {
+ return new JSONTraceWriter(stream);
+}
+
+} // namespace tracing
+} // namespace platform
+} // namespace v8
« no previous file with comments | « src/libplatform/tracing/trace-writer.h ('k') | src/libplatform/tracing/tracing-controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698