summaryrefslogtreecommitdiffstats
path: root/base/field_trial.cc
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-01 01:14:56 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-01 01:14:56 +0000
commitb37fdaafc215e5fea29b7f66fb866a0400ca47bb (patch)
tree6cf4a612fe7f2c95260f3c7a540816cf22570d04 /base/field_trial.cc
parente7aa9ec4e73aef9681c5bccb83b9d88aaab304fe (diff)
downloadchromium_src-b37fdaafc215e5fea29b7f66fb866a0400ca47bb.zip
chromium_src-b37fdaafc215e5fea29b7f66fb866a0400ca47bb.tar.gz
chromium_src-b37fdaafc215e5fea29b7f66fb866a0400ca47bb.tar.bz2
Implement shortcut for finalizing a trial with all remaining probability
It is helpful when defining experiments to put all remaining probability on the final (often the "control" group), without having to keep a careful tally of assignments of probabilities. This CL implements that functionality. r=rvargas Review URL: http://codereview.chromium.org/150141 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19696 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/field_trial.cc')
-rw-r--r--base/field_trial.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/base/field_trial.cc b/base/field_trial.cc
index 549822f..2b354d7 100644
--- a/base/field_trial.cc
+++ b/base/field_trial.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2009 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.
@@ -36,10 +36,15 @@ FieldTrial::FieldTrial(const std::string& name,
int FieldTrial::AppendGroup(const std::string& name,
Probability group_probability) {
DCHECK(group_probability <= divisor_);
- accumulated_group_probability_ += group_probability;
+ DCHECK(group_probability >=0 ||
+ group_probability == kAllRemainingProbability);
+ if (group_probability == kAllRemainingProbability)
+ accumulated_group_probability_ = divisor_;
+ else
+ 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 teh assignment.
+ // This is the group that crossed the random line, so we do the assignment.
group_ = next_group_number_;
if (name.empty())
StringAppendF(&group_name_, "_%d", group_);