From b37fdaafc215e5fea29b7f66fb866a0400ca47bb Mon Sep 17 00:00:00 2001 From: "jar@chromium.org" Date: Wed, 1 Jul 2009 01:14:56 +0000 Subject: 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 --- base/field_trial.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'base/field_trial.cc') 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_); -- cgit v1.1