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

Unified Diff: base/tracked_objects.cc

Issue 8888004: Minor cleanup preparing for recording parent-child data (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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 | « base/tracked_objects.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/tracked_objects.cc
===================================================================
--- base/tracked_objects.cc (revision 113567)
+++ base/tracked_objects.cc (working copy)
@@ -43,7 +43,7 @@
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 @@
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_; }
« no previous file with comments | « base/tracked_objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698