diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-07 22:54:27 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-07 22:54:27 +0000 |
commit | e8d82c6124232e1678eb242e5c7369bd20ac949d (patch) | |
tree | 4248307bc59b2e0491ce67cf146ba3e9942d1d0c /base | |
parent | 956702425b4ce15cdfc433491519f1df19f3d3fc (diff) | |
download | chromium_src-e8d82c6124232e1678eb242e5c7369bd20ac949d.zip chromium_src-e8d82c6124232e1678eb242e5c7369bd20ac949d.tar.gz chromium_src-e8d82c6124232e1678eb242e5c7369bd20ac949d.tar.bz2 |
Turn off field trials and reporting of metrics when running benchmarking.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/5628005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68532 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/metrics/field_trial.cc | 24 | ||||
-rw-r--r-- | base/metrics/field_trial.h | 10 |
2 files changed, 32 insertions, 2 deletions
diff --git a/base/metrics/field_trial.cc b/base/metrics/field_trial.cc index 63d9ed5..d29ed2d 100644 --- a/base/metrics/field_trial.cc +++ b/base/metrics/field_trial.cc @@ -17,6 +17,9 @@ const int FieldTrial::kNotParticipating = -1; const int FieldTrial::kAllRemainingProbability = -2; // static +bool FieldTrial::enable_benchmarking_ = false; + +// static const char FieldTrialList::kPersistentStringSeparator('/'); static const char kHistogramFieldTrialSeparator('_'); @@ -40,10 +43,13 @@ int FieldTrial::AppendGroup(const std::string& name, DCHECK(group_probability <= divisor_); DCHECK(group_probability >=0 || group_probability == kAllRemainingProbability); - if (group_probability == kAllRemainingProbability) + if (group_probability == kAllRemainingProbability) { accumulated_group_probability_ = divisor_; - else + } else { + if (enable_benchmarking_) + group_probability = 0; accumulated_group_probability_ += group_probability; + } DCHECK(accumulated_group_probability_ <= divisor_); if (group_ == kNotParticipating && accumulated_group_probability_ > random_) { // This is the group that crossed the random line, so we do the assignment. @@ -64,6 +70,12 @@ std::string FieldTrial::MakeName(const std::string& name_prefix, return big_string.append(FieldTrialList::FindFullName(trial_name)); } +// static +void FieldTrial::EnableBenchmarking() { + DCHECK_EQ(0u, FieldTrialList::GetFieldTrialCount()); + enable_benchmarking_ = true; +} + FieldTrial::~FieldTrial() {} //------------------------------------------------------------------------------ @@ -190,4 +202,12 @@ bool FieldTrialList::StringAugmentsState(const std::string& prior_state) { return true; } +// static +size_t FieldTrialList::GetFieldTrialCount() { + if (!global_) + return 0; + AutoLock auto_lock(global_->lock_); + return global_->registered_.size(); +} + } // namespace base diff --git a/base/metrics/field_trial.h b/base/metrics/field_trial.h index 348a1a7..1f0af9e 100644 --- a/base/metrics/field_trial.h +++ b/base/metrics/field_trial.h @@ -117,6 +117,9 @@ class FieldTrial : public RefCounted<FieldTrial> { static std::string MakeName(const std::string& name_prefix, const std::string& trial_name); + // Enable benchmarking sets field trials to a common setting. + static void EnableBenchmarking(); + private: friend class RefCounted<FieldTrial>; @@ -148,6 +151,10 @@ class FieldTrial : public RefCounted<FieldTrial> { // If this Trial is not a member of an group, this string is empty. std::string group_name_; + // When benchmarking is enabled, field trials all revert to the 'default' + // bucket. + static bool enable_benchmarking_; + DISALLOW_COPY_AND_ASSIGN(FieldTrial); }; @@ -206,6 +213,9 @@ class FieldTrialList { return TimeTicks::Now(); } + // Return the number of active field trials. + static size_t GetFieldTrialCount(); + private: // Helper function should be called only while holding lock_. FieldTrial* PreLockedFind(const std::string& name); |