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

Side by Side Diff: chrome/common/metrics/variations/uniformity_field_trials.cc

Issue 12447006: Forward declare base::Time in uniformity trials. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 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
OLDNEW
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"
tfarina 2013/03/05 16:46:24 do you want to include base/time.h? now here?
SteveT 2013/03/05 17:54:24 Done.
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "chrome/common/metrics/variations/variations_util.h" 9 #include "chrome/common/metrics/variations/variations_util.h"
10 10
11 namespace { 11 namespace {
12 12
13 // Set up a uniformity field trial. |one_time_randomized| indicates if the 13 // 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| 14 // 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 15 // 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) 16 // the trial name. |num_trial_groups| must be a divisor of 100 (e.g. 5, 20)
17 void SetupSingleUniformityFieldTrial( 17 void SetupSingleUniformityFieldTrial(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 // Now that all groups have been appended, call group() on the trial to 63 // 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 64 // 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. 65 // where the default group never gets chosen if we don't "use" the trial.
66 const int chosen_group = trial->group(); 66 const int chosen_group = trial->group();
67 DVLOG(1) << "Chosen Group: " << chosen_group; 67 DVLOG(1) << "Chosen Group: " << chosen_group;
68 } 68 }
69 69
70 // Setup a 50% uniformity trial for new installs only. This is accomplished by 70 // 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. 71 // disabling the trial on clients that were installed before a specified date.
72 void SetupNewInstallUniformityTrial(const base::Time& install_date) { 72 void SetupNewInstallUniformityTrial(const base::Time& install_date) {
tfarina 2013/03/05 16:46:24 do you want to pass by value here too?
SteveT 2013/03/05 17:54:24 Done.
73 const base::Time::Exploded kStartDate = { 73 const base::Time::Exploded kStartDate = {
74 2012, 11, 0, 6, // Nov 6, 2012 74 2012, 11, 0, 6, // Nov 6, 2012
75 0, 0, 0, 0 // 00:00:00.000 75 0, 0, 0, 0 // 00:00:00.000
76 }; 76 };
77 scoped_refptr<base::FieldTrial> trial( 77 scoped_refptr<base::FieldTrial> trial(
78 base::FieldTrialList::FactoryGetFieldTrial( 78 base::FieldTrialList::FactoryGetFieldTrial(
79 "UMA-New-Install-Uniformity-Trial", 100, "Disabled", 79 "UMA-New-Install-Uniformity-Trial", 100, "Disabled",
80 2015, 1, 1, NULL)); 80 2015, 1, 1, NULL));
81 trial->UseOneTimeRandomization(); 81 trial->UseOneTimeRandomization();
82 trial->AppendGroup("Control", 50); 82 trial->AppendGroup("Control", 50);
83 trial->AppendGroup("Experiment", 50); 83 trial->AppendGroup("Experiment", 50);
84 const base::Time start_date = base::Time::FromLocalExploded(kStartDate); 84 const base::Time start_date = base::Time::FromLocalExploded(kStartDate);
85 if (install_date < start_date) 85 if (install_date < start_date)
86 trial->Disable(); 86 trial->Disable();
87 else 87 else
88 trial->group(); 88 trial->group();
89 } 89 }
90 90
91 } // namespace 91 } // namespace
92 92
93 namespace chrome_variations { 93 namespace chrome_variations {
94 94
95 void SetupUniformityFieldTrials(const base::Time& install_date) { 95 void SetupUniformityFieldTrials(const base::Time install_date) {
96 // One field trial will be created for each entry in this array. The i'th 96 // 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 97 // 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]|. 98 // group. Each group will have a probability of 1/|trial_sizes[i]|.
99 const int num_trial_groups[] = { 100, 20, 10, 5, 2 }; 99 const int num_trial_groups[] = { 100, 20, 10, 5, 2 };
100 100
101 // Declare our variation ID bases along side this array so we can loop over it 101 // 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 102 // and assign the IDs appropriately. So for example, the 1 percent experiments
103 // should have a size of 100 (100/100 = 1). 103 // should have a size of 100 (100/100 = 1).
104 const chrome_variations::VariationID trial_base_ids[] = { 104 const chrome_variations::VariationID trial_base_ids[] = {
105 chrome_variations::UNIFORMITY_1_PERCENT_BASE, 105 chrome_variations::UNIFORMITY_1_PERCENT_BASE,
(...skipping 13 matching lines...) Expand all
119 // Setup a 5% session-randomized uniformity trial. 119 // Setup a 5% session-randomized uniformity trial.
120 const std::string kSessionRandomizedTrialName = 120 const std::string kSessionRandomizedTrialName =
121 "UMA-Session-Randomized-Uniformity-Trial-%d-Percent"; 121 "UMA-Session-Randomized-Uniformity-Trial-%d-Percent";
122 SetupSingleUniformityFieldTrial(false, kSessionRandomizedTrialName, 122 SetupSingleUniformityFieldTrial(false, kSessionRandomizedTrialName,
123 chrome_variations::UNIFORMITY_SESSION_RANDOMIZED_5_PERCENT_BASE, 20); 123 chrome_variations::UNIFORMITY_SESSION_RANDOMIZED_5_PERCENT_BASE, 20);
124 124
125 SetupNewInstallUniformityTrial(install_date); 125 SetupNewInstallUniformityTrial(install_date);
126 } 126 }
127 127
128 } // namespace chrome_variations 128 } // namespace chrome_variations
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698