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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 // Return the randomly selected group number that was assigned. | 105 // Return the randomly selected group number that was assigned. |
106 // Return kNotParticipating if the instance is not participating in the | 106 // Return kNotParticipating if the instance is not participating in the |
107 // experiment. | 107 // experiment. |
108 int group() const { return group_; } | 108 int group() const { return group_; } |
109 | 109 |
110 // If the field trial is not in an experiment, this returns the empty string. | 110 // If the field trial is not in an experiment, this returns the empty string. |
111 // if the group's name is empty, a name of "_" concatenated with the group | 111 // if the group's name is empty, a name of "_" concatenated with the group |
112 // number is used as the group name. | 112 // number is used as the group name. |
113 std::string group_name() const { return group_name_; } | 113 std::string group_name() const { return group_name_; } |
114 | 114 |
115 // Set the duration after which we will disable Field Trials. We will subtract | |
116 // build time from application start time and if the difference is greater | |
117 // than the duration that is specified via the following function, then we | |
118 // disable field trails and the field trials revert to the 'default' bucket. | |
119 void SetDurationAfterWhichDisableFieldTrials(base::TimeDelta duration) { | |
jar (doing other things)
2011/01/09 07:00:04
nit: for classes as arguments, pass in:
const CLAS
jar (doing other things)
2011/01/09 07:00:04
nit: Since this is an instance of FieldTrial, we o
rtenneti
2011/01/09 23:16:42
Done.
rtenneti
2011/01/09 23:16:42
Done.
| |
120 duration_after_which_disable_field_trials_ = duration; | |
121 } | |
122 base::TimeDelta durationAfterWhichDisableFieldTrials() { | |
123 return duration_after_which_disable_field_trials_; | |
124 } | |
125 | |
115 // Helper function for the most common use: as an argument to specifiy the | 126 // Helper function for the most common use: as an argument to specifiy the |
116 // name of a HISTOGRAM. Use the original histogram name as the name_prefix. | 127 // name of a HISTOGRAM. Use the original histogram name as the name_prefix. |
117 static std::string MakeName(const std::string& name_prefix, | 128 static std::string MakeName(const std::string& name_prefix, |
118 const std::string& trial_name); | 129 const std::string& trial_name); |
119 | 130 |
120 // Enable benchmarking sets field trials to a common setting. | 131 // Enable benchmarking sets field trials to a common setting. |
121 static void EnableBenchmarking(); | 132 static void EnableBenchmarking(); |
122 | 133 |
134 // Get build time. | |
135 static Time GetBuildTime(); | |
136 | |
123 private: | 137 private: |
124 friend class RefCounted<FieldTrial>; | 138 friend class RefCounted<FieldTrial>; |
125 | 139 |
126 virtual ~FieldTrial(); | 140 virtual ~FieldTrial(); |
127 | 141 |
128 // The name of the field trial, as can be found via the FieldTrialList. | 142 // The name of the field trial, as can be found via the FieldTrialList. |
129 // This is empty of the trial is not in the experiment. | 143 // This is empty of the trial is not in the experiment. |
130 const std::string name_; | 144 const std::string name_; |
131 | 145 |
132 // The maximum sum of all probabilities supplied, which corresponds to 100%. | 146 // The maximum sum of all probabilities supplied, which corresponds to 100%. |
133 // This is the scaling factor used to adjust supplied probabilities. | 147 // This is the scaling factor used to adjust supplied probabilities. |
134 Probability divisor_; | 148 Probability divisor_; |
135 | 149 |
136 // The randomly selected probability that is used to select a group (or have | 150 // The randomly selected probability that is used to select a group (or have |
137 // the instance not participate). It is the product of divisor_ and a random | 151 // the instance not participate). It is the product of divisor_ and a random |
138 // number between [0, 1). | 152 // number between [0, 1). |
139 Probability random_; | 153 Probability random_; |
140 | 154 |
141 // Sum of the probabilities of all appended groups. | 155 // Sum of the probabilities of all appended groups. |
142 Probability accumulated_group_probability_; | 156 Probability accumulated_group_probability_; |
143 | 157 |
144 int next_group_number_; | 158 int next_group_number_; |
145 | 159 |
160 // duration after which we should disable field_trails. | |
161 base::TimeDelta duration_after_which_disable_field_trials_; | |
162 | |
163 bool disable_field_trails_; | |
164 | |
146 // The pseudo-randomly assigned group number. | 165 // The pseudo-randomly assigned group number. |
147 // This is kNotParticipating if no group has been assigned. | 166 // This is kNotParticipating if no group has been assigned. |
148 int group_; | 167 int group_; |
149 | 168 |
150 // A textual name for the randomly selected group, including the Trial name. | 169 // A textual name for the randomly selected group, including the Trial name. |
151 // If this Trial is not a member of an group, this string is empty. | 170 // If this Trial is not a member of an group, this string is empty. |
152 std::string group_name_; | 171 std::string group_name_; |
153 | 172 |
154 // When benchmarking is enabled, field trials all revert to the 'default' | 173 // When benchmarking is enabled, field trials all revert to the 'default' |
155 // bucket. | 174 // bucket. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 Lock lock_; | 258 Lock lock_; |
240 RegistrationList registered_; | 259 RegistrationList registered_; |
241 | 260 |
242 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); | 261 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); |
243 }; | 262 }; |
244 | 263 |
245 } // namespace base | 264 } // namespace base |
246 | 265 |
247 #endif // BASE_METRICS_FIELD_TRIAL_H_ | 266 #endif // BASE_METRICS_FIELD_TRIAL_H_ |
248 | 267 |
OLD | NEW |