OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/counters.h" | 5 #include "src/counters.h" |
6 | 6 |
7 #include <iomanip> | 7 #include <iomanip> |
8 | 8 |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 uint64_t total_call_count = 0; | 270 uint64_t total_call_count = 0; |
271 base::TimeDelta total_time; | 271 base::TimeDelta total_time; |
272 std::vector<Entry> entries; | 272 std::vector<Entry> entries; |
273 }; | 273 }; |
274 | 274 |
275 void RuntimeCallCounter::Reset() { | 275 void RuntimeCallCounter::Reset() { |
276 count = 0; | 276 count = 0; |
277 time = base::TimeDelta(); | 277 time = base::TimeDelta(); |
278 } | 278 } |
279 | 279 |
280 void RuntimeCallCounter::Dump(std::stringstream& out) { | 280 void RuntimeCallCounter::Dump(v8::tracing::TracedValue* value) { |
281 out << "\"" << name << "\":[" << count << "," << time.InMicroseconds() | 281 value->BeginArray(name); |
282 << "],"; | 282 value->AppendLongInteger(count); |
| 283 value->AppendLongInteger(time.InMicroseconds()); |
| 284 value->EndArray(); |
283 } | 285 } |
284 | 286 |
285 // static | 287 // static |
286 void RuntimeCallStats::Enter(RuntimeCallStats* stats, RuntimeCallTimer* timer, | 288 void RuntimeCallStats::Enter(RuntimeCallStats* stats, RuntimeCallTimer* timer, |
287 CounterId counter_id) { | 289 CounterId counter_id) { |
288 RuntimeCallCounter* counter = &(stats->*counter_id); | 290 RuntimeCallCounter* counter = &(stats->*counter_id); |
289 timer->Start(counter, stats->current_timer_); | 291 timer->Start(counter, stats->current_timer_); |
290 stats->current_timer_ = timer; | 292 stats->current_timer_ = timer; |
291 } | 293 } |
292 | 294 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 FOR_EACH_API_COUNTER(RESET_COUNTER) | 360 FOR_EACH_API_COUNTER(RESET_COUNTER) |
359 #undef RESET_COUNTER | 361 #undef RESET_COUNTER |
360 | 362 |
361 #define RESET_COUNTER(name) this->Handler_##name.Reset(); | 363 #define RESET_COUNTER(name) this->Handler_##name.Reset(); |
362 FOR_EACH_HANDLER_COUNTER(RESET_COUNTER) | 364 FOR_EACH_HANDLER_COUNTER(RESET_COUNTER) |
363 #undef RESET_COUNTER | 365 #undef RESET_COUNTER |
364 | 366 |
365 in_use_ = true; | 367 in_use_ = true; |
366 } | 368 } |
367 | 369 |
368 std::string RuntimeCallStats::Dump() { | 370 void RuntimeCallStats::Dump(v8::tracing::TracedValue* value) { |
369 buffer_.str(std::string()); | |
370 buffer_.clear(); | |
371 buffer_ << "{"; | |
372 #define DUMP_COUNTER(name) \ | 371 #define DUMP_COUNTER(name) \ |
373 if (this->name.count > 0) this->name.Dump(buffer_); | 372 if (this->name.count > 0) this->name.Dump(value); |
374 FOR_EACH_MANUAL_COUNTER(DUMP_COUNTER) | 373 FOR_EACH_MANUAL_COUNTER(DUMP_COUNTER) |
375 #undef DUMP_COUNTER | 374 #undef DUMP_COUNTER |
376 | 375 |
377 #define DUMP_COUNTER(name, nargs, result_size) \ | 376 #define DUMP_COUNTER(name, nargs, result_size) \ |
378 if (this->Runtime_##name.count > 0) this->Runtime_##name.Dump(buffer_); | 377 if (this->Runtime_##name.count > 0) this->Runtime_##name.Dump(value); |
379 FOR_EACH_INTRINSIC(DUMP_COUNTER) | 378 FOR_EACH_INTRINSIC(DUMP_COUNTER) |
380 #undef DUMP_COUNTER | 379 #undef DUMP_COUNTER |
381 | 380 |
382 #define DUMP_COUNTER(name) \ | 381 #define DUMP_COUNTER(name) \ |
383 if (this->Builtin_##name.count > 0) this->Builtin_##name.Dump(buffer_); | 382 if (this->Builtin_##name.count > 0) this->Builtin_##name.Dump(value); |
384 BUILTIN_LIST_C(DUMP_COUNTER) | 383 BUILTIN_LIST_C(DUMP_COUNTER) |
385 #undef DUMP_COUNTER | 384 #undef DUMP_COUNTER |
386 | 385 |
387 #define DUMP_COUNTER(name) \ | 386 #define DUMP_COUNTER(name) \ |
388 if (this->API_##name.count > 0) this->API_##name.Dump(buffer_); | 387 if (this->API_##name.count > 0) this->API_##name.Dump(value); |
389 FOR_EACH_API_COUNTER(DUMP_COUNTER) | 388 FOR_EACH_API_COUNTER(DUMP_COUNTER) |
390 #undef DUMP_COUNTER | 389 #undef DUMP_COUNTER |
391 | 390 |
392 #define DUMP_COUNTER(name) \ | 391 #define DUMP_COUNTER(name) \ |
393 if (this->Handler_##name.count > 0) this->Handler_##name.Dump(buffer_); | 392 if (this->Handler_##name.count > 0) this->Handler_##name.Dump(value); |
394 FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER) | 393 FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER) |
395 #undef DUMP_COUNTER | 394 #undef DUMP_COUNTER |
396 buffer_ << "\"END\":[]}"; | 395 |
397 in_use_ = false; | 396 in_use_ = false; |
398 return buffer_.str(); | |
399 } | 397 } |
400 | 398 |
401 } // namespace internal | 399 } // namespace internal |
402 } // namespace v8 | 400 } // namespace v8 |
OLD | NEW |