OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // FieldTrial is a class for handling details of statistical experiments | 5 // FieldTrial is a class for handling details of statistical experiments |
6 // performed by actual users in the field (i.e., in a shipped or beta product). | 6 // performed by actual users in the field (i.e., in a shipped or beta product). |
7 // All code is called exclusively on the UI thread currently. | 7 // All code is called exclusively on the UI thread currently. |
8 // | 8 // |
9 // The simplest example is an experiment to see whether one of two options | 9 // The simplest example is an experiment to see whether one of two options |
10 // produces "better" results across our user population. In that scenario, UMA | 10 // produces "better" results across our user population. In that scenario, UMA |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // to the total_probability. Arguments year, month and day_of_month specify | 94 // to the total_probability. Arguments year, month and day_of_month specify |
95 // the expiration time. If the build time is after the expiration time then | 95 // the expiration time. If the build time is after the expiration time then |
96 // the field trial reverts to the 'default' group. | 96 // the field trial reverts to the 'default' group. |
97 FieldTrial(const std::string& name, Probability total_probability, | 97 FieldTrial(const std::string& name, Probability total_probability, |
98 const std::string& default_group_name, const int year, | 98 const std::string& default_group_name, const int year, |
99 const int month, const int day_of_month); | 99 const int month, const int day_of_month); |
100 | 100 |
101 // Establish the name and probability of the next group in this trial. | 101 // Establish the name and probability of the next group in this trial. |
102 // Sometimes, based on construction randomization, this call may cause the | 102 // Sometimes, based on construction randomization, this call may cause the |
103 // provided group to be *THE* group selected for use in this instance. | 103 // provided group to be *THE* group selected for use in this instance. |
| 104 // The return value is the group number of the new group. |
104 int AppendGroup(const std::string& name, Probability group_probability); | 105 int AppendGroup(const std::string& name, Probability group_probability); |
105 | 106 |
106 // Return the name of the FieldTrial (excluding the group name). | 107 // Return the name of the FieldTrial (excluding the group name). |
107 std::string name() const { return name_; } | 108 std::string name() const { return name_; } |
108 | 109 |
109 // Return the randomly selected group number that was assigned. | 110 // Return the randomly selected group number that was assigned. |
110 // Return kDefaultGroupNumber if the instance is in the 'default' group. | 111 // Return kDefaultGroupNumber if the instance is in the 'default' group. |
111 // Note that this will force an instance to participate, and make it illegal | 112 // Note that this will force an instance to participate, and make it illegal |
112 // to attempt to probabalistically add any other groups to the trial. | 113 // to attempt to probabalistically add any other groups to the trial. |
113 int group(); | 114 int group(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // The maximum sum of all probabilities supplied, which corresponds to 100%. | 161 // The maximum sum of all probabilities supplied, which corresponds to 100%. |
161 // This is the scaling factor used to adjust supplied probabilities. | 162 // This is the scaling factor used to adjust supplied probabilities. |
162 const Probability divisor_; | 163 const Probability divisor_; |
163 | 164 |
164 // The name of the default group. | 165 // The name of the default group. |
165 const std::string default_group_name_; | 166 const std::string default_group_name_; |
166 | 167 |
167 // The randomly selected probability that is used to select a group (or have | 168 // The randomly selected probability that is used to select a group (or have |
168 // the instance not participate). It is the product of divisor_ and a random | 169 // the instance not participate). It is the product of divisor_ and a random |
169 // number between [0, 1). | 170 // number between [0, 1). |
170 Probability random_; | 171 const Probability random_; |
171 | 172 |
172 // Sum of the probabilities of all appended groups. | 173 // Sum of the probabilities of all appended groups. |
173 Probability accumulated_group_probability_; | 174 Probability accumulated_group_probability_; |
174 | 175 |
175 int next_group_number_; | 176 int next_group_number_; |
176 | 177 |
177 // The pseudo-randomly assigned group number. | 178 // The pseudo-randomly assigned group number. |
178 // This is kNotFinalized if no group has been assigned. | 179 // This is kNotFinalized if no group has been assigned. |
179 int group_; | 180 int group_; |
180 | 181 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 base::Lock lock_; | 275 base::Lock lock_; |
275 RegistrationList registered_; | 276 RegistrationList registered_; |
276 | 277 |
277 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); | 278 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); |
278 }; | 279 }; |
279 | 280 |
280 } // namespace base | 281 } // namespace base |
281 | 282 |
282 #endif // BASE_METRICS_FIELD_TRIAL_H_ | 283 #endif // BASE_METRICS_FIELD_TRIAL_H_ |
283 | 284 |
OLD | NEW |