OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "chrome/common/metrics/variations/uniformity_field_trials.h" | 5 #include "chrome/common/metrics/variations/uniformity_field_trials.h" |
6 | 6 |
7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "base/time.h" |
9 #include "chrome/common/metrics/variations/variations_util.h" | 10 #include "chrome/common/metrics/variations/variations_util.h" |
10 | 11 |
11 namespace { | 12 namespace { |
12 | 13 |
13 // Set up a uniformity field trial. |one_time_randomized| indicates if the | 14 // Set up a uniformity field trial. |one_time_randomized| indicates if the |
14 // field trial is one-time randomized or session-randomized. |trial_name_string| | 15 // field trial is one-time randomized or session-randomized. |trial_name_string| |
15 // must contain a "%d" since the percentage of the group will be inserted in | 16 // must contain a "%d" since the percentage of the group will be inserted in |
16 // the trial name. |num_trial_groups| must be a divisor of 100 (e.g. 5, 20) | 17 // the trial name. |num_trial_groups| must be a divisor of 100 (e.g. 5, 20) |
17 void SetupSingleUniformityFieldTrial( | 18 void SetupSingleUniformityFieldTrial( |
18 bool one_time_randomized, | 19 bool one_time_randomized, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 63 |
63 // Now that all groups have been appended, call group() on the trial to | 64 // Now that all groups have been appended, call group() on the trial to |
64 // ensure that our trial is registered. This resolves an off-by-one issue | 65 // ensure that our trial is registered. This resolves an off-by-one issue |
65 // where the default group never gets chosen if we don't "use" the trial. | 66 // where the default group never gets chosen if we don't "use" the trial. |
66 const int chosen_group = trial->group(); | 67 const int chosen_group = trial->group(); |
67 DVLOG(1) << "Chosen Group: " << chosen_group; | 68 DVLOG(1) << "Chosen Group: " << chosen_group; |
68 } | 69 } |
69 | 70 |
70 // Setup a 50% uniformity trial for new installs only. This is accomplished by | 71 // Setup a 50% uniformity trial for new installs only. This is accomplished by |
71 // disabling the trial on clients that were installed before a specified date. | 72 // disabling the trial on clients that were installed before a specified date. |
72 void SetupNewInstallUniformityTrial(const base::Time& install_date) { | 73 void SetupNewInstallUniformityTrial(const base::Time install_date) { |
73 const base::Time::Exploded kStartDate = { | 74 const base::Time::Exploded kStartDate = { |
74 2012, 11, 0, 6, // Nov 6, 2012 | 75 2012, 11, 0, 6, // Nov 6, 2012 |
75 0, 0, 0, 0 // 00:00:00.000 | 76 0, 0, 0, 0 // 00:00:00.000 |
76 }; | 77 }; |
77 scoped_refptr<base::FieldTrial> trial( | 78 scoped_refptr<base::FieldTrial> trial( |
78 base::FieldTrialList::FactoryGetFieldTrial( | 79 base::FieldTrialList::FactoryGetFieldTrial( |
79 "UMA-New-Install-Uniformity-Trial", 100, "Disabled", | 80 "UMA-New-Install-Uniformity-Trial", 100, "Disabled", |
80 2015, 1, 1, NULL)); | 81 2015, 1, 1, NULL)); |
81 trial->UseOneTimeRandomization(); | 82 trial->UseOneTimeRandomization(); |
82 trial->AppendGroup("Control", 50); | 83 trial->AppendGroup("Control", 50); |
83 trial->AppendGroup("Experiment", 50); | 84 trial->AppendGroup("Experiment", 50); |
84 const base::Time start_date = base::Time::FromLocalExploded(kStartDate); | 85 const base::Time start_date = base::Time::FromLocalExploded(kStartDate); |
85 if (install_date < start_date) | 86 if (install_date < start_date) |
86 trial->Disable(); | 87 trial->Disable(); |
87 else | 88 else |
88 trial->group(); | 89 trial->group(); |
89 } | 90 } |
90 | 91 |
91 } // namespace | 92 } // namespace |
92 | 93 |
93 namespace chrome_variations { | 94 namespace chrome_variations { |
94 | 95 |
95 void SetupUniformityFieldTrials(const base::Time& install_date) { | 96 void SetupUniformityFieldTrials(const base::Time install_date) { |
96 // One field trial will be created for each entry in this array. The i'th | 97 // One field trial will be created for each entry in this array. The i'th |
97 // field trial will have |trial_sizes[i]| groups in it, including the default | 98 // field trial will have |trial_sizes[i]| groups in it, including the default |
98 // group. Each group will have a probability of 1/|trial_sizes[i]|. | 99 // group. Each group will have a probability of 1/|trial_sizes[i]|. |
99 const int num_trial_groups[] = { 100, 20, 10, 5, 2 }; | 100 const int num_trial_groups[] = { 100, 20, 10, 5, 2 }; |
100 | 101 |
101 // Declare our variation ID bases along side this array so we can loop over it | 102 // Declare our variation ID bases along side this array so we can loop over it |
102 // and assign the IDs appropriately. So for example, the 1 percent experiments | 103 // and assign the IDs appropriately. So for example, the 1 percent experiments |
103 // should have a size of 100 (100/100 = 1). | 104 // should have a size of 100 (100/100 = 1). |
104 const chrome_variations::VariationID trial_base_ids[] = { | 105 const chrome_variations::VariationID trial_base_ids[] = { |
105 chrome_variations::UNIFORMITY_1_PERCENT_BASE, | 106 chrome_variations::UNIFORMITY_1_PERCENT_BASE, |
(...skipping 13 matching lines...) Expand all Loading... |
119 // Setup a 5% session-randomized uniformity trial. | 120 // Setup a 5% session-randomized uniformity trial. |
120 const std::string kSessionRandomizedTrialName = | 121 const std::string kSessionRandomizedTrialName = |
121 "UMA-Session-Randomized-Uniformity-Trial-%d-Percent"; | 122 "UMA-Session-Randomized-Uniformity-Trial-%d-Percent"; |
122 SetupSingleUniformityFieldTrial(false, kSessionRandomizedTrialName, | 123 SetupSingleUniformityFieldTrial(false, kSessionRandomizedTrialName, |
123 chrome_variations::UNIFORMITY_SESSION_RANDOMIZED_5_PERCENT_BASE, 20); | 124 chrome_variations::UNIFORMITY_SESSION_RANDOMIZED_5_PERCENT_BASE, 20); |
124 | 125 |
125 SetupNewInstallUniformityTrial(install_date); | 126 SetupNewInstallUniformityTrial(install_date); |
126 } | 127 } |
127 | 128 |
128 } // namespace chrome_variations | 129 } // namespace chrome_variations |
OLD | NEW |