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

Side by Side Diff: chrome/browser/prerender/prerender_field_trial.cc

Issue 9705074: Supporting command line argument to force field trials (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/prerender/prerender_field_trial.h" 5 #include "chrome/browser/prerender/prerender_field_trial.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 13 matching lines...) Expand all
24 24
25 void SetupPrefetchFieldTrial() { 25 void SetupPrefetchFieldTrial() {
26 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); 26 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
27 if (channel == chrome::VersionInfo::CHANNEL_STABLE || 27 if (channel == chrome::VersionInfo::CHANNEL_STABLE ||
28 channel == chrome::VersionInfo::CHANNEL_BETA) { 28 channel == chrome::VersionInfo::CHANNEL_BETA) {
29 return; 29 return;
30 } 30 }
31 31
32 const base::FieldTrial::Probability divisor = 1000; 32 const base::FieldTrial::Probability divisor = 1000;
33 const base::FieldTrial::Probability prefetch_probability = 500; 33 const base::FieldTrial::Probability prefetch_probability = 500;
34 scoped_refptr<base::FieldTrial> trial( 34 scoped_refptr<base::FieldTrial> trial(base::FieldTrial::CreateInstance(
35 new base::FieldTrial("Prefetch", divisor, 35 "Prefetch", divisor, "ContentPrefetchPrefetchOff", 2012, 6, 30));
36 "ContentPrefetchPrefetchOff", 2012, 6, 30));
37 const int kPrefetchOnGroup = trial->AppendGroup("ContentPrefetchPrefetchOn", 36 const int kPrefetchOnGroup = trial->AppendGroup("ContentPrefetchPrefetchOn",
38 prefetch_probability); 37 prefetch_probability);
39 PrerenderManager::SetIsPrefetchEnabled(trial->group() == kPrefetchOnGroup); 38 PrerenderManager::SetIsPrefetchEnabled(trial->group() == kPrefetchOnGroup);
40 } 39 }
41 40
42 void SetupPrerenderFieldTrial() { 41 void SetupPrerenderFieldTrial() {
43 base::FieldTrial::Probability divisor = 1000; 42 base::FieldTrial::Probability divisor = 1000;
44 43
45 base::FieldTrial::Probability exp1_probability = 166; 44 base::FieldTrial::Probability exp1_probability = 166;
46 base::FieldTrial::Probability exp1_5min_ttl_probability = 83; 45 base::FieldTrial::Probability exp1_5min_ttl_probability = 83;
(...skipping 14 matching lines...) Expand all
61 no_use1_probability = 0; 60 no_use1_probability = 0;
62 exp2_probability = 490; 61 exp2_probability = 490;
63 exp2_5min_ttl_probability = 5; 62 exp2_5min_ttl_probability = 5;
64 control2_probability = 5; 63 control2_probability = 5;
65 no_use2_probability = 0; 64 no_use2_probability = 0;
66 } 65 }
67 CHECK_EQ(divisor, exp1_probability + exp1_5min_ttl_probability + 66 CHECK_EQ(divisor, exp1_probability + exp1_5min_ttl_probability +
68 control1_probability + no_use1_probability + exp2_probability + 67 control1_probability + no_use1_probability + exp2_probability +
69 exp2_5min_ttl_probability + control2_probability + 68 exp2_5min_ttl_probability + control2_probability +
70 no_use2_probability); 69 no_use2_probability);
71 scoped_refptr<base::FieldTrial> trial( 70 scoped_refptr<base::FieldTrial> trial(base::FieldTrial::CreateInstance(
72 new base::FieldTrial("Prerender", divisor, 71 "Prerender", divisor, "ContentPrefetchPrerender1", 2012, 6, 30));
73 "ContentPrefetchPrerender1", 2012, 6, 30));
74 72
75 const int kExperiment1Group = trial->kDefaultGroupNumber; 73 const int kExperiment1Group = trial->kDefaultGroupNumber;
76 const int kExperiment15minTTLGroup = 74 const int kExperiment15minTTLGroup =
77 trial->AppendGroup("ContentPrefetchPrerenderExp5minTTL1", 75 trial->AppendGroup("ContentPrefetchPrerenderExp5minTTL1",
78 exp1_5min_ttl_probability); 76 exp1_5min_ttl_probability);
79 const int kControl1Group = 77 const int kControl1Group =
80 trial->AppendGroup("ContentPrefetchPrerenderControl1", 78 trial->AppendGroup("ContentPrefetchPrerenderControl1",
81 control1_probability); 79 control1_probability);
82 const int kNoUse1Group = 80 const int kNoUse1Group =
83 trial->AppendGroup("ContentPrefetchPrerenderNoUse1", 81 trial->AppendGroup("ContentPrefetchPrerenderNoUse1",
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 // Field trial to see if we're enabled. 183 // Field trial to see if we're enabled.
186 const base::FieldTrial::Probability kDivisor = 100; 184 const base::FieldTrial::Probability kDivisor = 100;
187 185
188 base::FieldTrial::Probability kDisabledProbability = 10; 186 base::FieldTrial::Probability kDisabledProbability = 10;
189 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); 187 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
190 if (channel == chrome::VersionInfo::CHANNEL_STABLE || 188 if (channel == chrome::VersionInfo::CHANNEL_STABLE ||
191 channel == chrome::VersionInfo::CHANNEL_BETA) { 189 channel == chrome::VersionInfo::CHANNEL_BETA) {
192 kDisabledProbability = 1; 190 kDisabledProbability = 1;
193 } 191 }
194 scoped_refptr<base::FieldTrial> omnibox_prerender_trial( 192 scoped_refptr<base::FieldTrial> omnibox_prerender_trial(
195 new base::FieldTrial(kOmniboxTrialName, kDivisor, 193 base::FieldTrial::CreateInstance(
196 "OmniboxPrerenderEnabled", 2012, 8, 30)); 194 kOmniboxTrialName, kDivisor, "OmniboxPrerenderEnabled", 2012, 8, 30));
197 omnibox_prerender_trial->AppendGroup("OmniboxPrerenderDisabled", 195 omnibox_prerender_trial->AppendGroup("OmniboxPrerenderDisabled",
198 kDisabledProbability); 196 kDisabledProbability);
199 197
200 // Field trial to set weighting of hits. 198 // Field trial to set weighting of hits.
201 const base::FieldTrial::Probability kFourProbability = 33; 199 const base::FieldTrial::Probability kFourProbability = 33;
202 const base::FieldTrial::Probability kEightProbability = 33; 200 const base::FieldTrial::Probability kEightProbability = 33;
203 201
204 scoped_refptr<base::FieldTrial> weighting_trial( 202 scoped_refptr<base::FieldTrial> weighting_trial(
205 new base::FieldTrial("OmniboxPrerenderHitWeightingTrial", kDivisor, 203 base::FieldTrial::CreateInstance("OmniboxPrerenderHitWeightingTrial",
206 "OmniboxPrerenderWeight1.0", 2012, 8, 30)); 204 kDivisor, "OmniboxPrerenderWeight1.0",
205 2012, 8, 30));
207 const int kOmniboxWeightFourGroup = 206 const int kOmniboxWeightFourGroup =
208 weighting_trial->AppendGroup("OmniboxPrerenderWeight4.0", 207 weighting_trial->AppendGroup("OmniboxPrerenderWeight4.0",
209 kFourProbability); 208 kFourProbability);
210 const int kOmniboxWeightEightGroup = 209 const int kOmniboxWeightEightGroup =
211 weighting_trial->AppendGroup("OmniboxPrerenderWeight8.0", 210 weighting_trial->AppendGroup("OmniboxPrerenderWeight8.0",
212 kEightProbability); 211 kEightProbability);
213 const int group = weighting_trial->group(); 212 const int group = weighting_trial->group();
214 if (group == kOmniboxWeightFourGroup) 213 if (group == kOmniboxWeightFourGroup)
215 NetworkActionPredictor::set_hit_weight(4.0); 214 NetworkActionPredictor::set_hit_weight(4.0);
216 else if (group == kOmniboxWeightEightGroup) 215 else if (group == kOmniboxWeightEightGroup)
(...skipping 22 matching lines...) Expand all
239 238
240 DCHECK(switch_value == switches::kPrerenderFromOmniboxSwitchValueAuto); 239 DCHECK(switch_value == switches::kPrerenderFromOmniboxSwitchValueAuto);
241 } 240 }
242 241
243 const int group = base::FieldTrialList::FindValue(kOmniboxTrialName); 242 const int group = base::FieldTrialList::FindValue(kOmniboxTrialName);
244 return group == base::FieldTrial::kNotFinalized || 243 return group == base::FieldTrial::kNotFinalized ||
245 group == base::FieldTrial::kDefaultGroupNumber; 244 group == base::FieldTrial::kDefaultGroupNumber;
246 } 245 }
247 246
248 } // namespace prerender 247 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698