summaryrefslogtreecommitdiffstats
path: root/base/tracked_objects.cc
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-09 03:41:04 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-09 03:41:04 +0000
commit7ceb4448df82ced9a4a311923d0465e33444effe (patch)
tree1b7ea12dc1a90acc1431ba19d1cfe941c86785f6 /base/tracked_objects.cc
parent356dc759f225c84ed45075d87f3358936abaac36 (diff)
downloadchromium_src-7ceb4448df82ced9a4a311923d0465e33444effe.zip
chromium_src-7ceb4448df82ced9a4a311923d0465e33444effe.tar.gz
chromium_src-7ceb4448df82ced9a4a311923d0465e33444effe.tar.bz2
Minor cleanup preparing for recording parent-child data
I removed the branch-free macro. I really need to use a profiler to see if such changes are valuable. I cleaned up the placement of slots, putting the rare-to-use values together (so they'll probably get better handled by cache lines. r=rtenneti Review URL: http://codereview.chromium.org/8888004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113749 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/tracked_objects.cc')
-rw-r--r--base/tracked_objects.cc26
1 files changed, 11 insertions, 15 deletions
diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc
index ffb083b..614c17a 100644
--- a/base/tracked_objects.cc
+++ b/base/tracked_objects.cc
@@ -43,7 +43,7 @@ DeathData::DeathData(int count) {
count_ = count;
}
-// TODO(jar): I need to see if this macro to optimize branching is worth it.
+// TODO(jar): I need to see if this macro to optimize branching is worth using.
//
// This macro has no branching, so it is surely fast, and is equivalent to:
// if (assign_it)
@@ -56,28 +56,24 @@ DeathData::DeathData(int count) {
void DeathData::RecordDeath(const DurationInt queue_duration,
const DurationInt run_duration,
int32 random_number) {
+ ++count_;
queue_duration_sum_ += queue_duration;
run_duration_sum_ += run_duration;
- ++count_;
+
+ if (queue_duration_max_ < queue_duration)
+ queue_duration_max_ = queue_duration;
+ if (run_duration_max_ < run_duration)
+ run_duration_max_ = run_duration;
// Take a uniformly distributed sample over all durations ever supplied.
// The probability that we (instead) use this new sample is 1/count_. This
// results in a completely uniform selection of the sample.
// We ignore the fact that we correlated our selection of a sample of run
// and queue times.
- bool take_sample = 0 == (random_number % count_);
- CONDITIONAL_ASSIGN(take_sample, queue_duration_sample_, queue_duration);
- CONDITIONAL_ASSIGN(take_sample, run_duration_sample_, run_duration);
-
- CONDITIONAL_ASSIGN(queue_duration_max_ < queue_duration, queue_duration_max_,
- queue_duration);
- CONDITIONAL_ASSIGN(run_duration_max_ < run_duration, run_duration_max_,
- run_duration);
- // Ensure we got the macros right.
- DCHECK_GE(queue_duration_max_, queue_duration);
- DCHECK_GE(run_duration_max_, run_duration);
- DCHECK(!take_sample || run_duration_sample_ == run_duration);
- DCHECK(!take_sample || queue_duration_sample_ == queue_duration);
+ if (0 == (random_number % count_)) {
+ queue_duration_sample_ = queue_duration;
+ run_duration_sample_ = run_duration;
+ }
}
int DeathData::count() const { return count_; }