Chromium Code Reviews| 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/builtins/builtins-definitions.h" | 10 #include "src/builtins/builtins-definitions.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 void Histogram::AddSample(int sample) { | 70 void Histogram::AddSample(int sample) { |
| 71 if (Enabled()) { | 71 if (Enabled()) { |
| 72 counters_->AddHistogramSample(histogram_, sample); | 72 counters_->AddHistogramSample(histogram_, sample); |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 void* Histogram::CreateHistogram() const { | 76 void* Histogram::CreateHistogram() const { |
| 77 return counters_->CreateHistogram(name_, min_, max_, num_buckets_); | 77 return counters_->CreateHistogram(name_, min_, max_, num_buckets_); |
| 78 } | 78 } |
| 79 | 79 |
| 80 | 80 void TimedHistogram::Start(base::ElapsedTimer* timer, Isolate* isolate) { |
| 81 // Start the timer. | 81 if (Enabled()) timer->Start(); |
| 82 void HistogramTimer::Start() { | 82 if (isolate) Logger::CallEventLogger(isolate, name(), Logger::START, true); |
|
Mircea Trofin
2017/06/22 18:42:23
why would it not have an isolate?
also, for consi
kschimpf
2017/06/22 20:38:31
The only need for the isolate is for logging, and
| |
| 83 if (Enabled()) { | |
| 84 timer_.Start(); | |
| 85 } | |
| 86 Logger::CallEventLogger(counters()->isolate(), name(), Logger::START, true); | |
| 87 } | 83 } |
| 88 | 84 |
| 89 | 85 void TimedHistogram::Stop(base::ElapsedTimer* timer, Isolate* isolate) { |
| 90 // Stop the timer and record the results. | |
| 91 void HistogramTimer::Stop() { | |
| 92 if (Enabled()) { | 86 if (Enabled()) { |
| 93 int64_t sample = resolution_ == MICROSECOND | |
| 94 ? timer_.Elapsed().InMicroseconds() | |
| 95 : timer_.Elapsed().InMilliseconds(); | |
| 96 // Compute the delta between start and stop, in microseconds. | 87 // Compute the delta between start and stop, in microseconds. |
| 88 int64_t sample = resolution_ == HistogramTimerResolution::MICROSECOND | |
| 89 ? timer->Elapsed().InMicroseconds() | |
| 90 : timer->Elapsed().InMilliseconds(); | |
| 91 timer->Stop(); | |
| 97 AddSample(static_cast<int>(sample)); | 92 AddSample(static_cast<int>(sample)); |
| 98 timer_.Stop(); | |
| 99 } | 93 } |
| 100 Logger::CallEventLogger(counters()->isolate(), name(), Logger::END, true); | 94 if (isolate != nullptr) { |
| 95 Logger::CallEventLogger(isolate, name(), Logger::END, true); | |
| 96 } | |
| 101 } | 97 } |
| 102 | 98 |
| 103 Counters::Counters(Isolate* isolate) | 99 Counters::Counters(Isolate* isolate) |
| 104 : isolate_(isolate), | 100 : isolate_(isolate), |
| 105 stats_table_(this), | 101 stats_table_(this), |
| 106 // clang format off | 102 // clang format off |
| 107 #define SC(name, caption) name##_(this, "c:" #caption), | 103 #define SC(name, caption) name##_(this, "c:" #caption), |
| 108 STATS_COUNTER_TS_LIST(SC) | 104 STATS_COUNTER_TS_LIST(SC) |
| 109 #undef SC | 105 #undef SC |
| 110 // clang format on | 106 // clang format on |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 124 for (const auto& histogram : kHistograms) { | 120 for (const auto& histogram : kHistograms) { |
| 125 this->*histogram.member = | 121 this->*histogram.member = |
| 126 Histogram(histogram.caption, histogram.min, histogram.max, | 122 Histogram(histogram.caption, histogram.min, histogram.max, |
| 127 histogram.num_buckets, this); | 123 histogram.num_buckets, this); |
| 128 } | 124 } |
| 129 | 125 |
| 130 static const struct { | 126 static const struct { |
| 131 HistogramTimer Counters::*member; | 127 HistogramTimer Counters::*member; |
| 132 const char* caption; | 128 const char* caption; |
| 133 int max; | 129 int max; |
| 134 HistogramTimer::Resolution res; | 130 HistogramTimerResolution res; |
| 135 } kHistogramTimers[] = { | 131 } kHistogramTimers[] = { |
| 136 #define HT(name, caption, max, res) \ | 132 #define HT(name, caption, max, res) \ |
| 137 {&Counters::name##_, #caption, max, HistogramTimer::res}, | 133 {&Counters::name##_, #caption, max, HistogramTimerResolution::res}, |
| 138 HISTOGRAM_TIMER_LIST(HT) | 134 HISTOGRAM_TIMER_LIST(HT) |
| 139 #undef HT | 135 #undef HT |
| 140 }; | 136 }; |
| 141 for (const auto& timer : kHistogramTimers) { | 137 for (const auto& timer : kHistogramTimers) { |
| 142 this->*timer.member = | 138 this->*timer.member = |
| 143 HistogramTimer(timer.caption, 0, timer.max, timer.res, 50, this); | 139 HistogramTimer(timer.caption, 0, timer.max, timer.res, 50, this); |
| 144 } | 140 } |
| 145 | 141 |
| 146 static const struct { | 142 static const struct { |
| 143 TimedHistogram Counters::*member; | |
| 144 const char* caption; | |
| 145 int max; | |
| 146 HistogramTimerResolution res; | |
| 147 } kTimedHistograms[] = { | |
| 148 #define HT(name, caption, max, res) \ | |
| 149 {&Counters::name##_, #caption, max, HistogramTimerResolution::res}, | |
| 150 TIMED_HISTOGRAM_LIST(HT) | |
| 151 #undef HT | |
| 152 }; | |
| 153 for (const auto& timer : kTimedHistograms) { | |
| 154 this->*timer.member = | |
| 155 TimedHistogram(timer.caption, 0, timer.max, timer.res, 50, this); | |
|
Mircea Trofin
2017/06/22 18:42:23
what's "50" - I realize it's done the same above,
kschimpf
2017/06/22 20:38:31
Its the number of buckets. The current macros do n
| |
| 156 } | |
| 157 | |
| 158 static const struct { | |
| 147 AggregatableHistogramTimer Counters::*member; | 159 AggregatableHistogramTimer Counters::*member; |
| 148 const char* caption; | 160 const char* caption; |
| 149 } kAggregatableHistogramTimers[] = { | 161 } kAggregatableHistogramTimers[] = { |
| 150 #define AHT(name, caption) {&Counters::name##_, #caption}, | 162 #define AHT(name, caption) {&Counters::name##_, #caption}, |
| 151 AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT) | 163 AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT) |
| 152 #undef AHT | 164 #undef AHT |
| 153 }; | 165 }; |
| 154 for (const auto& aht : kAggregatableHistogramTimers) { | 166 for (const auto& aht : kAggregatableHistogramTimers) { |
| 155 this->*aht.member = | 167 this->*aht.member = |
| 156 AggregatableHistogramTimer(aht.caption, 0, 10000000, 50, this); | 168 AggregatableHistogramTimer(aht.caption, 0, 10000000, 50, this); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 stats_table_.SetCreateHistogramFunction(f); | 299 stats_table_.SetCreateHistogramFunction(f); |
| 288 | 300 |
| 289 #define HR(name, caption, min, max, num_buckets) name##_.Reset(); | 301 #define HR(name, caption, min, max, num_buckets) name##_.Reset(); |
| 290 HISTOGRAM_RANGE_LIST(HR) | 302 HISTOGRAM_RANGE_LIST(HR) |
| 291 #undef HR | 303 #undef HR |
| 292 | 304 |
| 293 #define HT(name, caption, max, res) name##_.Reset(); | 305 #define HT(name, caption, max, res) name##_.Reset(); |
| 294 HISTOGRAM_TIMER_LIST(HT) | 306 HISTOGRAM_TIMER_LIST(HT) |
| 295 #undef HT | 307 #undef HT |
| 296 | 308 |
| 309 #define HT(name, caption, max, res) name##_.Reset(); | |
| 310 TIMED_HISTOGRAM_LIST(HT) | |
| 311 #undef HT | |
| 312 | |
| 297 #define AHT(name, caption) name##_.Reset(); | 313 #define AHT(name, caption) name##_.Reset(); |
| 298 AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT) | 314 AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT) |
| 299 #undef AHT | 315 #undef AHT |
| 300 | 316 |
| 301 #define HP(name, caption) name##_.Reset(); | 317 #define HP(name, caption) name##_.Reset(); |
| 302 HISTOGRAM_PERCENTAGE_LIST(HP) | 318 HISTOGRAM_PERCENTAGE_LIST(HP) |
| 303 #undef HP | 319 #undef HP |
| 304 | 320 |
| 305 #define HM(name, caption) name##_.Reset(); | 321 #define HM(name, caption) name##_.Reset(); |
| 306 HISTOGRAM_LEGACY_MEMORY_LIST(HM) | 322 HISTOGRAM_LEGACY_MEMORY_LIST(HM) |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 554 RuntimeCallStats::counters) { | 570 RuntimeCallStats::counters) { |
| 555 RuntimeCallCounter* counter = &(this->*counter_id); | 571 RuntimeCallCounter* counter = &(this->*counter_id); |
| 556 if (counter->count() > 0) counter->Dump(value); | 572 if (counter->count() > 0) counter->Dump(value); |
| 557 } | 573 } |
| 558 | 574 |
| 559 in_use_ = false; | 575 in_use_ = false; |
| 560 } | 576 } |
| 561 | 577 |
| 562 } // namespace internal | 578 } // namespace internal |
| 563 } // namespace v8 | 579 } // namespace v8 |
| OLD | NEW |