Index: src/counters.cc |
diff --git a/src/counters.cc b/src/counters.cc |
index c4e86460aa1140054a09f1f0abc0a1350e4054da..7acd74a8a7f7a934ad377848bae75cc425870efa 100644 |
--- a/src/counters.cc |
+++ b/src/counters.cc |
@@ -276,11 +276,6 @@ void RuntimeCallCounter::Reset() { |
time = base::TimeDelta(); |
} |
-void RuntimeCallCounter::Dump(std::stringstream& out) { |
- out << "\"" << name << "\":[" << count << "," << time.InMicroseconds() |
- << "],"; |
-} |
- |
// static |
void RuntimeCallStats::Enter(RuntimeCallStats* stats, RuntimeCallTimer* timer, |
CounterId counter_id) { |
@@ -364,37 +359,43 @@ void RuntimeCallStats::Reset() { |
in_use_ = true; |
} |
-std::string RuntimeCallStats::Dump() { |
- buffer_.str(std::string()); |
- buffer_.clear(); |
- buffer_ << "{"; |
+void RuntimeCallStats::Dump(v8::tracing::TracedValue* value) { |
+#define DUMP(counter) \ |
+ if (counter.count > 0) { \ |
+ value->BeginArray(counter.name); \ |
+ value->AppendLongInteger(counter.count); \ |
+ value->AppendLongInteger(counter.time.InMicroseconds()); \ |
+ value->EndArray(); \ |
+ } |
Camillo Bruni
2016/10/18 07:52:24
Please leave the separate function in place as the
lpy
2016/10/18 19:43:44
Done.
|
+ |
#define DUMP_COUNTER(name) \ |
- if (this->name.count > 0) this->name.Dump(buffer_); |
+ if (this->name.count > 0) DUMP(this->name) |
FOR_EACH_MANUAL_COUNTER(DUMP_COUNTER) |
#undef DUMP_COUNTER |
#define DUMP_COUNTER(name, nargs, result_size) \ |
- if (this->Runtime_##name.count > 0) this->Runtime_##name.Dump(buffer_); |
+ if (this->Runtime_##name.count > 0) DUMP(this->Runtime_##name); |
FOR_EACH_INTRINSIC(DUMP_COUNTER) |
#undef DUMP_COUNTER |
#define DUMP_COUNTER(name) \ |
- if (this->Builtin_##name.count > 0) this->Builtin_##name.Dump(buffer_); |
+ if (this->Builtin_##name.count > 0) DUMP(this->Builtin_##name); |
BUILTIN_LIST_C(DUMP_COUNTER) |
#undef DUMP_COUNTER |
#define DUMP_COUNTER(name) \ |
- if (this->API_##name.count > 0) this->API_##name.Dump(buffer_); |
+ if (this->API_##name.count > 0) DUMP(this->API_##name); |
FOR_EACH_API_COUNTER(DUMP_COUNTER) |
#undef DUMP_COUNTER |
#define DUMP_COUNTER(name) \ |
- if (this->Handler_##name.count > 0) this->Handler_##name.Dump(buffer_); |
+ if (this->Handler_##name.count > 0) DUMP(this->Handler_##name); |
FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER) |
#undef DUMP_COUNTER |
- buffer_ << "\"END\":[]}"; |
+ |
in_use_ = false; |
- return buffer_.str(); |
+ |
+#undef DUMP |
} |
} // namespace internal |