Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: base/metrics/field_trial.h

Issue 6213001: disable field trials if the build is 30 days or older (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/metrics/field_trial.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // histograms will get unique names via the MakeName() methods. 87 // histograms will get unique names via the MakeName() methods.
88 static const Probability kAllRemainingProbability; 88 static const Probability kAllRemainingProbability;
89 89
90 // The name is used to register the instance with the FieldTrialList class, 90 // The name is used to register the instance with the FieldTrialList class,
91 // and can be used to find the trial (only one trial can be present for each 91 // and can be used to find the trial (only one trial can be present for each
92 // name). 92 // name).
93 // Group probabilities that are later supplied must sum to less than or equal 93 // Group probabilities that are later supplied must sum to less than or equal
94 // to the total_probability. 94 // to the total_probability.
95 FieldTrial(const std::string& name, Probability total_probability); 95 FieldTrial(const std::string& name, Probability total_probability);
96 96
97 // Determine if the field trial is to be disabled or not based on
98 // disable_duration_, build time of the module and Now(). This method sets
99 // disable_field_trail_ to true, if the difference between build time of the
jar (doing other things) 2011/01/10 22:01:21 nit: trail-->trial
rtenneti 2011/01/10 22:48:03 Done.
100 // module and Now() is greater than disable_duration_. If disable_field_trail_
101 // is true then the field trial reverts to the 'default' bucket.
102 void FieldTrial::DetermineIfFieldTrailIsToBeDisabled();
103
97 // Establish the name and probability of the next group in this trial. 104 // Establish the name and probability of the next group in this trial.
98 // Sometimes, based on construction randomization, this call may causes the 105 // Sometimes, based on construction randomization, this call may causes the
99 // provided group to be *THE* group selected for use in this instance. 106 // provided group to be *THE* group selected for use in this instance.
100 int AppendGroup(const std::string& name, Probability group_probability); 107 int AppendGroup(const std::string& name, Probability group_probability);
101 108
102 // Return the name of the FieldTrial (excluding the group name). 109 // Return the name of the FieldTrial (excluding the group name).
103 std::string name() const { return name_; } 110 std::string name() const { return name_; }
104 111
105 // Return the randomly selected group number that was assigned. 112 // Return the randomly selected group number that was assigned.
106 // Return kNotParticipating if the instance is not participating in the 113 // Return kNotParticipating if the instance is not participating in the
107 // experiment. 114 // experiment.
108 int group() const { return group_; } 115 int group() const { return group_; }
109 116
110 // If the field trial is not in an experiment, this returns the empty string. 117 // 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 118 // if the group's name is empty, a name of "_" concatenated with the group
112 // number is used as the group name. 119 // number is used as the group name.
113 std::string group_name() const { return group_name_; } 120 std::string group_name() const { return group_name_; }
114 121
122 // Set the duration from build time of the module to disable Field Trial.
123 void SetDisableDuration(const base::TimeDelta& duration);
124
125 base::TimeDelta disableDuration() const {
jar (doing other things) 2011/01/10 22:01:21 nit: Reading this name, it looks like the duration
rtenneti 2011/01/10 22:48:03 Hi Jim, UsageTimeout seems to read better. Going
rtenneti 2011/01/10 22:48:03 Done.
126 return disable_duration_;
127 }
128
115 // Helper function for the most common use: as an argument to specifiy the 129 // 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. 130 // name of a HISTOGRAM. Use the original histogram name as the name_prefix.
117 static std::string MakeName(const std::string& name_prefix, 131 static std::string MakeName(const std::string& name_prefix,
118 const std::string& trial_name); 132 const std::string& trial_name);
119 133
120 // Enable benchmarking sets field trials to a common setting. 134 // Enable benchmarking sets field trials to a common setting.
121 static void EnableBenchmarking(); 135 static void EnableBenchmarking();
122 136
137 // Get build time.
138 static Time GetBuildTime();
139
123 private: 140 private:
124 friend class RefCounted<FieldTrial>; 141 friend class RefCounted<FieldTrial>;
125 142
126 virtual ~FieldTrial(); 143 virtual ~FieldTrial();
127 144
128 // The name of the field trial, as can be found via the FieldTrialList. 145 // 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. 146 // This is empty of the trial is not in the experiment.
130 const std::string name_; 147 const std::string name_;
131 148
132 // The maximum sum of all probabilities supplied, which corresponds to 100%. 149 // The maximum sum of all probabilities supplied, which corresponds to 100%.
133 // This is the scaling factor used to adjust supplied probabilities. 150 // This is the scaling factor used to adjust supplied probabilities.
134 Probability divisor_; 151 Probability divisor_;
135 152
136 // The randomly selected probability that is used to select a group (or have 153 // 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 154 // the instance not participate). It is the product of divisor_ and a random
138 // number between [0, 1). 155 // number between [0, 1).
139 Probability random_; 156 Probability random_;
140 157
141 // Sum of the probabilities of all appended groups. 158 // Sum of the probabilities of all appended groups.
142 Probability accumulated_group_probability_; 159 Probability accumulated_group_probability_;
143 160
144 int next_group_number_; 161 int next_group_number_;
145 162
163 // The default value (all remaining probabilities) can be selected after the
164 // duration, which is based on the build time of the module.
165 base::TimeDelta disable_duration_;
166
167 // When disable_field_trail_ is true, field trial reverts to the 'default'
168 // bucket.
169 bool disable_field_trail_;
170
146 // The pseudo-randomly assigned group number. 171 // The pseudo-randomly assigned group number.
147 // This is kNotParticipating if no group has been assigned. 172 // This is kNotParticipating if no group has been assigned.
148 int group_; 173 int group_;
149 174
150 // A textual name for the randomly selected group, including the Trial name. 175 // 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. 176 // If this Trial is not a member of an group, this string is empty.
152 std::string group_name_; 177 std::string group_name_;
153 178
154 // When benchmarking is enabled, field trials all revert to the 'default' 179 // When benchmarking is enabled, field trials all revert to the 'default'
155 // bucket. 180 // bucket.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 Lock lock_; 264 Lock lock_;
240 RegistrationList registered_; 265 RegistrationList registered_;
241 266
242 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); 267 DISALLOW_COPY_AND_ASSIGN(FieldTrialList);
243 }; 268 };
244 269
245 } // namespace base 270 } // namespace base
246 271
247 #endif // BASE_METRICS_FIELD_TRIAL_H_ 272 #endif // BASE_METRICS_FIELD_TRIAL_H_
248 273
OLDNEW
« no previous file with comments | « no previous file | base/metrics/field_trial.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698