| 1370 | } |
| 1371 | |
| 1372 | void RuntimeProfile::ToJsonSubclass( |
| 1373 | Verbosity verbosity, Value* parent, Document* d) const { |
| 1374 | Document::AllocatorType& allocator = d->GetAllocator(); |
| 1375 | // 1. Events |
| 1376 | { |
| 1377 | lock_guard<SpinLock> l(event_sequence_lock_); |
| 1378 | if (!event_sequence_map_.empty()) { |
| 1379 | Value event_sequences_json(kArrayType); |
| 1380 | for (EventSequenceMap::const_iterator it = event_sequence_map_.begin(); |
| 1381 | it != event_sequence_map_.end(); ++it) { |
| 1382 | Value event_sequence_json(kObjectType); |
| 1383 | it->second->ToJson(verbosity, *d, &event_sequence_json); |
| 1384 | event_sequences_json.PushBack(event_sequence_json, allocator); |
| 1385 | } |
| 1386 | parent->AddMember("event_sequences", event_sequences_json, allocator); |
| 1387 | } |
| 1388 | } |
| 1389 | |
| 1390 | // 2. Time_series_counter_map |
| 1391 | { |
| 1392 | // Print all time series counters as following: |
| 1393 | // - <Name> (<period>): <val1>, <val2>, <etc> |
| 1394 | lock_guard<SpinLock> l(counter_map_lock_); |
| 1395 | if (!time_series_counter_map_.empty()) { |
| 1396 | Value time_series_counters_json(kArrayType); |
| 1397 | for (const TimeSeriesCounterMap::value_type& v : time_series_counter_map_) { |
| 1398 | TimeSeriesCounter* counter = v.second; |
| 1399 | Value time_series_json(kObjectType); |
| 1400 | counter->ToJson(verbosity, *d, &time_series_json); |
| 1401 | time_series_counters_json.PushBack(time_series_json, allocator); |
| 1402 | } |
| 1403 | parent->AddMember("time_series_counters", time_series_counters_json, allocator); |
| 1404 | } |
| 1405 | } |
| 1406 | |
| 1407 | // 3. SummaryStatsCounter |
| 1408 | { |
| 1409 | lock_guard<SpinLock> l(summary_stats_map_lock_); |
| 1410 | if (!summary_stats_map_.empty()) { |
| 1411 | Value summary_stats_counters_json(kArrayType); |
| 1412 | for (const SummaryStatsCounterMap::value_type& v : summary_stats_map_) { |
| 1413 | Value summary_stats_counter(kObjectType); |
| 1414 | Value summary_name_json(v.first, allocator); |
| 1415 | v.second->ToJson(verbosity, *d, &summary_stats_counter); |
| 1416 | summary_stats_counter.AddMember("counter_name", summary_name_json, allocator); |
| 1417 | summary_stats_counters_json.PushBack(summary_stats_counter, allocator); |
| 1418 | } |
| 1419 | parent->AddMember("summary_stats_counters", summary_stats_counters_json, allocator); |
| 1420 | } |
| 1421 | } |
| 1422 | } |
| 1423 | |
| 1424 | void RuntimeProfileBase::PrettyPrint(ostream* s, const string& prefix) const { |
| 1425 | PrettyPrint(DefaultVerbosity(), s, prefix); |