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

Side by Side Diff: base/field_trial.h

Issue 150141: Implement shortcut for finalizing a trial with all remaining probability... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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/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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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
11 // data is uploaded to aggregate the test results, and this FieldTrial class 11 // data is uploaded to aggregate the test results, and this FieldTrial class
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // SetMemoryModel(LOW); // Sample alternate setting. 43 // SetMemoryModel(LOW); // Sample alternate setting.
44 44
45 // We then modify any histograms we wish to correlate with our experiment to 45 // We then modify any histograms we wish to correlate with our experiment to
46 // have slighly different names, depending on what group the trial instance 46 // have slighly different names, depending on what group the trial instance
47 // happened (randomly) to be assigned to: 47 // happened (randomly) to be assigned to:
48 48
49 // HISTOGRAM_COUNTS(FieldTrial::MakeName("Memory.RendererTotal", 49 // HISTOGRAM_COUNTS(FieldTrial::MakeName("Memory.RendererTotal",
50 // "MemoryExperiment").data(), count); 50 // "MemoryExperiment").data(), count);
51 51
52 // The above code will create 3 distinct histograms, with each run of the 52 // The above code will create 3 distinct histograms, with each run of the
53 // application being assigned to of of teh three groups, and for each group, the 53 // application being assigned to of of the three groups, and for each group, the
54 // correspondingly named histogram will be populated: 54 // correspondingly named histogram will be populated:
55 55
56 // Memory.RendererTotal // 96% of users still fill this histogram. 56 // Memory.RendererTotal // 96% of users still fill this histogram.
57 // Memory.RendererTotal_high_mem // 2% of users will fill this histogram. 57 // Memory.RendererTotal_high_mem // 2% of users will fill this histogram.
58 // Memory.RendererTotal_low_mem // 2% of users will fill this histogram. 58 // Memory.RendererTotal_low_mem // 2% of users will fill this histogram.
59 59
60 //------------------------------------------------------------------------------ 60 //------------------------------------------------------------------------------
61 61
62 #ifndef BASE_FIELD_TRIAL_H_ 62 #ifndef BASE_FIELD_TRIAL_H_
63 #define BASE_FIELD_TRIAL_H_ 63 #define BASE_FIELD_TRIAL_H_
64 64
65 #include <map> 65 #include <map>
66 #include <string> 66 #include <string>
67 67
68 #include "base/lock.h" 68 #include "base/lock.h"
69 #include "base/ref_counted.h" 69 #include "base/ref_counted.h"
70 #include "base/time.h" 70 #include "base/time.h"
71 71
72 72
73 class FieldTrial : public base::RefCounted<FieldTrial> { 73 class FieldTrial : public base::RefCounted<FieldTrial> {
74 public: 74 public:
75 typedef int Probability; // Probability type for being selected in a trial. 75 typedef int Probability; // Probability type for being selected in a trial.
76 76
77 // A return value to indicate that a given instance has not yet had a group 77 // A return value to indicate that a given instance has not yet had a group
78 // assignment (and hence is not yet participating in the trial). 78 // assignment (and hence is not yet participating in the trial).
79 static const int kNotParticipating; 79 static const int kNotParticipating;
80 80
81 // Provide an easy way to assign all remaining probability to a group. Note 81 // Provide an easy way to assign all remaining probability to a group. Note
82 // that this will force an instance to participate, and make it illegal to 82 // that this will force an instance to participate, and make it illegal to
83 // attempt to probabalistically add any other groups to the trial. 83 // attempt to probabalistically add any other groups to the trial. When doing
84 // A/B tests with timings, it is often best to define all groups, so that
85 // histograms will get unique names via the MakeName() methods.
84 static const Probability kAllRemainingProbability; 86 static const Probability kAllRemainingProbability;
85 87
86 // The name is used to register the instance with the FieldTrialList class, 88 // The name is used to register the instance with the FieldTrialList class,
87 // and can be used to find the trial (only one trial can be present for each 89 // and can be used to find the trial (only one trial can be present for each
88 // name). 90 // name).
89 // Group probabilities that are later supplied must sum to less than or equal 91 // Group probabilities that are later supplied must sum to less than or equal
90 // to the total_probability. 92 // to the total_probability.
91 FieldTrial(const std::string& name, Probability total_probability); 93 FieldTrial(const std::string& name, Probability total_probability);
92 94
93 // Establish the name and probability of the next group in this trial. 95 // Establish the name and probability of the next group in this trial.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 217
216 // Lock for access to registered_. 218 // Lock for access to registered_.
217 Lock lock_; 219 Lock lock_;
218 RegistrationList registered_; 220 RegistrationList registered_;
219 221
220 DISALLOW_COPY_AND_ASSIGN(FieldTrialList); 222 DISALLOW_COPY_AND_ASSIGN(FieldTrialList);
221 }; 223 };
222 224
223 #endif // BASE_FIELD_TRIAL_H_ 225 #endif // BASE_FIELD_TRIAL_H_
224 226
OLDNEW
« no previous file with comments | « no previous file | base/field_trial.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698