Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(818)

Unified Diff: src/counters.cc

Issue 2423: POD initialize StatsCounters (Closed)
Patch Set: Merge to HEAD Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/counters.h ('k') | src/v8-counters.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/counters.cc
diff --git a/src/counters.cc b/src/counters.cc
index b828874aa7644596da3aef8df36a2d51d26ee8a6..8878ec560a5f62cd12db231edfe1b1428220e11f 100644
--- a/src/counters.cc
+++ b/src/counters.cc
@@ -34,19 +34,9 @@ namespace v8 { namespace internal {
CounterLookupCallback StatsTable::lookup_function_ = NULL;
-StatsCounterTimer::StatsCounterTimer(const wchar_t* name)
- : start_time_(0), // initialize to avoid compiler complaints
- stop_time_(0) { // initialize to avoid compiler complaints
- int len = wcslen(name);
- // we prepend the name with 'c.' to indicate that it is a counter.
- name_ = Vector<wchar_t>::New(len+3);
- OS::WcsCpy(name_, L"t:");
- OS::WcsCpy(name_ + 2, name);
-}
-
// Start the timer.
void StatsCounterTimer::Start() {
- if (!Enabled())
+ if (!counter_.Enabled())
return;
stop_time_ = 0;
start_time_ = OS::Ticks();
@@ -54,10 +44,13 @@ void StatsCounterTimer::Start() {
// Stop the timer and record the results.
void StatsCounterTimer::Stop() {
- if (!Enabled())
+ if (!counter_.Enabled())
return;
stop_time_ = OS::Ticks();
- Record();
+
+ // Compute the delta between start and stop, in milliseconds.
+ int milliseconds = static_cast<int>(stop_time_ - start_time_) / 1000;
+ counter_.Increment(milliseconds);
}
} } // namespace v8::internal
« no previous file with comments | « src/counters.h ('k') | src/v8-counters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698