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

Side by Side 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: Start/StopTracing + TestTracingController 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/libplatform/tracing/trace-writer.h"
6
7 #include "src/base/platform/platform.h"
8
9 namespace v8 {
10 namespace platform {
11 namespace tracing {
12
13 JSONTraceWriter::JSONTraceWriter(std::ostream& stream) : stream_(stream) {
14 stream_ << "{\"traceEvents\":[";
15 }
16
17 JSONTraceWriter::~JSONTraceWriter() { stream_ << "]}"; }
18
19 void JSONTraceWriter::AppendTraceEvent(TraceObject* trace_event) {
20 if (append_comma_) stream_ << ",";
21 append_comma_ = true;
22 stream_ << "{\"pid\":" << trace_event->pid()
23 << ",\"tid\":" << trace_event->tid()
24 << ",\"ts\":" << trace_event->ts()
25 << ",\"tts\":" << trace_event->tts() << ",\"ph\":\""
26 << trace_event->phase() << "\",\"cat\":\""
27 << trace_event->category_group() << "\",\"name\":\""
28 << trace_event->name()
29 << "\",\"args\":{},\"dur\":" << trace_event->duration()
30 << ",\"tdur\":" << trace_event->cpu_duration() << "}";
31 }
32
33 void JSONTraceWriter::Flush() {}
34
35 TraceWriter* TraceWriter::CreateJSONTraceWriter(std::ostream& stream) {
36 return new JSONTraceWriter(stream);
37 }
38
39 } // namespace tracing
40 } // namespace platform
41 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698