diff options
-rw-r--r-- | base/profiler/tracked_time.cc | 6 | ||||
-rw-r--r-- | base/profiler/tracked_time.h | 19 | ||||
-rw-r--r-- | base/profiler/tracked_time_unittest.cc | 6 | ||||
-rw-r--r-- | base/tracked_objects.cc | 36 | ||||
-rw-r--r-- | base/tracked_objects.h | 32 | ||||
-rw-r--r-- | base/tracked_objects_unittest.cc | 4 |
6 files changed, 37 insertions, 66 deletions
diff --git a/base/profiler/tracked_time.cc b/base/profiler/tracked_time.cc index 0e227bd..f1edd6d 100644 --- a/base/profiler/tracked_time.cc +++ b/base/profiler/tracked_time.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,8 +12,6 @@ namespace tracked_objects { -#if defined(USE_FAST_TIME_CLASS_FOR_DURATION_CALCULATIONS) - Duration::Duration() : ms_(0) {} Duration::Duration(int32 duration) : ms_(duration) {} @@ -75,6 +73,4 @@ TrackedTime TrackedTime::operator+(const Duration& other) const { bool TrackedTime::is_null() const { return ms_ == 0; } -#endif // USE_FAST_TIME_CLASS_FOR_DURATION_CALCULATIONS - } // namespace tracked_objects diff --git a/base/profiler/tracked_time.h b/base/profiler/tracked_time.h index 5493e20..372c753 100644 --- a/base/profiler/tracked_time.h +++ b/base/profiler/tracked_time.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,14 +12,8 @@ namespace tracked_objects { -typedef int DurationInt; - //------------------------------------------------------------------------------ -#define USE_FAST_TIME_CLASS_FOR_DURATION_CALCULATIONS - -#if defined(USE_FAST_TIME_CLASS_FOR_DURATION_CALCULATIONS) - // TimeTicks maintains a wasteful 64 bits of data (we need less than 32), and on // windows, a 64 bit timer is expensive to even obtain. We use a simple // millisecond counter for most of our time values, as well as millisecond units @@ -72,17 +66,6 @@ class BASE_EXPORT TrackedTime { // Similar to base::TimeTicks. uint32 ms_; }; -#else - -// Just use full 64 bit time calculations, and the slower TimeTicks::Now(). -// This allows us (as an alternative) to test with larger ranges of times, and -// with a more thoroughly tested class. - -typedef base::TimeTicks TrackedTime; -typedef base::TimeDelta Duration; - -#endif // USE_FAST_TIME_CLASS_FOR_DURATION_CALCULATIONS - } // namespace tracked_objects #endif // BASE_PROFILER_TRACKED_TIME_H_ diff --git a/base/profiler/tracked_time_unittest.cc b/base/profiler/tracked_time_unittest.cc index b85411d..cd7f18c 100644 --- a/base/profiler/tracked_time_unittest.cc +++ b/base/profiler/tracked_time_unittest.cc @@ -28,14 +28,8 @@ TEST(TrackedTimeTest, TrackedTimerMilliseconds) { EXPECT_EQ(kReallyBigMilliseconds, (big - base::TimeTicks()).InMilliseconds()); TrackedTime wrapped_big(big); -#if defined(USE_FAST_TIME_CLASS_FOR_DURATION_CALCULATIONS) // Expect wrapping at 32 bits. EXPECT_EQ(kSomeMilliseconds, (wrapped_big - TrackedTime()).InMilliseconds()); -#else // !USE_FAST_TIME_CLASS_FOR_DURATION_CALCULATIONS) - // Expect no wrapping at 32 bits. - EXPECT_EQ(kReallyBigMilliseconds, - (wrapped_big - TrackedTime()).InMilliseconds()); -#endif // USE_FAST_TIME_CLASS_FOR_DURATION_CALCULATIONS) } TEST(TrackedTimeTest, TrackedTimerDuration) { diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc index f854134..1db578e 100644 --- a/base/tracked_objects.cc +++ b/base/tracked_objects.cc @@ -66,10 +66,10 @@ DeathData::DeathData(int count) { // We use a macro rather than a template to force this to inline. // Related code for calculating max is discussed on the web. #define CONDITIONAL_ASSIGN(assign_it, target, source) \ - ((target) ^= ((target) ^ (source)) & -static_cast<DurationInt>(assign_it)) + ((target) ^= ((target) ^ (source)) & -static_cast<int32>(assign_it)) -void DeathData::RecordDeath(const DurationInt queue_duration, - const DurationInt run_duration, +void DeathData::RecordDeath(const int32 queue_duration, + const int32 run_duration, int32 random_number) { ++count_; queue_duration_sum_ += queue_duration; @@ -93,23 +93,23 @@ void DeathData::RecordDeath(const DurationInt queue_duration, int DeathData::count() const { return count_; } -DurationInt DeathData::run_duration_sum() const { return run_duration_sum_; } +int32 DeathData::run_duration_sum() const { return run_duration_sum_; } -DurationInt DeathData::run_duration_max() const { return run_duration_max_; } +int32 DeathData::run_duration_max() const { return run_duration_max_; } -DurationInt DeathData::run_duration_sample() const { +int32 DeathData::run_duration_sample() const { return run_duration_sample_; } -DurationInt DeathData::queue_duration_sum() const { +int32 DeathData::queue_duration_sum() const { return queue_duration_sum_; } -DurationInt DeathData::queue_duration_max() const { +int32 DeathData::queue_duration_max() const { return queue_duration_max_; } -DurationInt DeathData::queue_duration_sample() const { +int32 DeathData::queue_duration_sample() const { return queue_duration_sample_; } @@ -374,10 +374,10 @@ Births* ThreadData::TallyABirth(const Location& location) { } void ThreadData::TallyADeath(const Births& birth, - DurationInt queue_duration, - DurationInt run_duration) { + int32 queue_duration, + int32 run_duration) { // Stir in some randomness, plus add constant in case durations are zero. - const DurationInt kSomePrimeNumber = 2147483647; + const int32 kSomePrimeNumber = 2147483647; random_number_ += queue_duration + run_duration + kSomePrimeNumber; // An address is going to have some randomness to it as well ;-). random_number_ ^= static_cast<int32>(&birth - reinterpret_cast<Births*>(0)); @@ -452,8 +452,8 @@ void ThreadData::TallyRunOnNamedThreadIfTracking( // get a time value since we "weren't tracking" and we were trying to be // efficient by not calling for a genuine time value. For simplicity, we'll // use a default zero duration when we can't calculate a true value. - DurationInt queue_duration = 0; - DurationInt run_duration = 0; + int32 queue_duration = 0; + int32 run_duration = 0; if (!start_of_run.is_null()) { queue_duration = (start_of_run - effective_post_time).InMilliseconds(); if (!end_of_run.is_null()) @@ -490,8 +490,8 @@ void ThreadData::TallyRunOnWorkerThreadIfTracking( if (!current_thread_data) return; - DurationInt queue_duration = 0; - DurationInt run_duration = 0; + int32 queue_duration = 0; + int32 run_duration = 0; if (!start_of_run.is_null()) { queue_duration = (start_of_run - time_posted).InMilliseconds(); if (!end_of_run.is_null()) @@ -518,8 +518,8 @@ void ThreadData::TallyRunInAScopedRegionIfTracking( if (!current_thread_data) return; - DurationInt queue_duration = 0; - DurationInt run_duration = 0; + int32 queue_duration = 0; + int32 run_duration = 0; if (!start_of_run.is_null() && !end_of_run.is_null()) run_duration = (end_of_run - start_of_run).InMilliseconds(); current_thread_data->TallyADeath(*birth, queue_duration, run_duration); diff --git a/base/tracked_objects.h b/base/tracked_objects.h index cd50594..e09b70b30 100644 --- a/base/tracked_objects.h +++ b/base/tracked_objects.h @@ -261,18 +261,18 @@ class BASE_EXPORT DeathData { // Update stats for a task destruction (death) that had a Run() time of // |duration|, and has had a queueing delay of |queue_duration|. - void RecordDeath(const DurationInt queue_duration, - const DurationInt run_duration, + void RecordDeath(const int32 queue_duration, + const int32 run_duration, int random_number); // Metrics accessors, used only in tests. int count() const; - DurationInt run_duration_sum() const; - DurationInt run_duration_max() const; - DurationInt run_duration_sample() const; - DurationInt queue_duration_sum() const; - DurationInt queue_duration_max() const; - DurationInt queue_duration_sample() const; + int32 run_duration_sum() const; + int32 run_duration_max() const; + int32 run_duration_sample() const; + int32 queue_duration_sum() const; + int32 queue_duration_max() const; + int32 queue_duration_sample() const; // Construct a DictionaryValue instance containing all our stats. The caller // assumes ownership of the returned instance. @@ -290,16 +290,16 @@ class BASE_EXPORT DeathData { // Number of runs seen (divisor for calculating averages). int count_; // Basic tallies, used to compute averages. - DurationInt run_duration_sum_; - DurationInt queue_duration_sum_; + int32 run_duration_sum_; + int32 queue_duration_sum_; // Max values, used by local visualization routines. These are often read, // but rarely updated. - DurationInt run_duration_max_; - DurationInt queue_duration_max_; + int32 run_duration_max_; + int32 queue_duration_max_; // Samples, used by by crowd sourcing gatherers. These are almost never read, // and rarely updated. - DurationInt run_duration_sample_; - DurationInt queue_duration_sample_; + int32 run_duration_sample_; + int32 queue_duration_sample_; }; //------------------------------------------------------------------------------ @@ -514,9 +514,7 @@ class BASE_EXPORT ThreadData { Births* TallyABirth(const Location& location); // Find a place to record a death on this thread. - void TallyADeath(const Births& birth, - DurationInt queue_duration, - DurationInt duration); + void TallyADeath(const Births& birth, int32 queue_duration, int32 duration); // Using our lock, make a copy of the specified maps. This call may be made // on non-local threads, which necessitate the use of the lock to prevent diff --git a/base/tracked_objects_unittest.cc b/base/tracked_objects_unittest.cc index 837a449..0e188b1 100644 --- a/base/tracked_objects_unittest.cc +++ b/base/tracked_objects_unittest.cc @@ -227,8 +227,8 @@ TEST_F(TrackedObjectsTest, DeathDataTest) { EXPECT_EQ(data->queue_duration_sample(), 0); EXPECT_EQ(data->count(), 0); - DurationInt run_ms = 42; - DurationInt queue_ms = 8; + int32 run_ms = 42; + int32 queue_ms = 8; const int kUnrandomInt = 0; // Fake random int that ensure we sample data. data->RecordDeath(queue_ms, run_ms, kUnrandomInt); |