OLD | NEW |
(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 |
OLD | NEW |