diff options
author | jar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-19 17:45:21 +0000 |
---|---|---|
committer | jar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-19 17:45:21 +0000 |
commit | ac262c9fd9775f9d85c42eaf42fccb896ba790ba (patch) | |
tree | 666a943e0537d6fdad0bf393ff0dd6939ee13b53 /chrome/browser | |
parent | aef3555aa83038b26b50cfab04d685e0f6dfc04f (diff) | |
download | chromium_src-ac262c9fd9775f9d85c42eaf42fccb896ba790ba.zip chromium_src-ac262c9fd9775f9d85c42eaf42fccb896ba790ba.tar.gz chromium_src-ac262c9fd9775f9d85c42eaf42fccb896ba790ba.tar.bz2 |
Construct a field trial to see if HIGH or MEDIUM memory model "works better"
Includes definition of a FieldTrial class to support this.
I have thoughts in my head about how this will eventually
extend to be controllable via UMA (as well as being able
to run tests defined at compile time, as was done in this
example.
r=mbelshe, mmentovai
Review URL: http://codereview.chromium.org/7638
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3604 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser.vcproj | 8 | ||||
-rw-r--r-- | chrome/browser/browser_main.cc | 19 | ||||
-rw-r--r-- | chrome/browser/browser_process_impl.cc | 13 | ||||
-rw-r--r-- | chrome/browser/browser_trial.cc | 8 | ||||
-rw-r--r-- | chrome/browser/browser_trial.h | 22 | ||||
-rw-r--r-- | chrome/browser/render_widget_host_view_win.cc | 17 |
6 files changed, 77 insertions, 10 deletions
diff --git a/chrome/browser/browser.vcproj b/chrome/browser/browser.vcproj index e2a5f7e..2edc607 100644 --- a/chrome/browser/browser.vcproj +++ b/chrome/browser/browser.vcproj @@ -2103,6 +2103,14 @@ </File> </Filter> <File + RelativePath=".\browser_trial.cc" + > + </File> + <File + RelativePath=".\browser_trial.h" + > + </File> + <File RelativePath=".\cert_store.cc" > </File> diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 5171c43..104a93f 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -24,6 +24,7 @@ #include "chrome/browser/browser_prefs.h" #include "chrome/browser/browser_process_impl.h" #include "chrome/browser/browser_shutdown.h" +#include "chrome/browser/browser_trial.h" #include "chrome/browser/cert_store.h" #include "chrome/browser/dom_ui/chrome_url_data_manager.h" #include "chrome/browser/first_run.h" @@ -238,7 +239,7 @@ bool CheckMachineLevelInstall() { std::transform(user_exe_path.begin(), user_exe_path.end(), user_exe_path.begin(), tolower); if (exe == user_exe_path) { - const std::wstring text = + const std::wstring text = l10n_util::GetString(IDS_MACHINE_LEVEL_INSTALL_CONFLICT); const std::wstring caption = l10n_util::GetString(IDS_PRODUCT_NAME); const UINT flags = MB_OK | MB_ICONERROR | MB_TOPMOST; @@ -280,6 +281,9 @@ int BrowserMain(CommandLine &parsed_command_line, int show_command, MessageLoop main_message_loop(MessageLoop::TYPE_UI); + // Initialize statistical testing infrastructure. + FieldTrialList field_trial; + std::wstring app_name = chrome::kBrowserAppName; std::string thread_name_string = WideToASCII(app_name + L"_BrowserMain"); @@ -320,7 +324,7 @@ int BrowserMain(CommandLine &parsed_command_line, int show_command, bool is_first_run = FirstRun::IsChromeFirstRun() || parsed_command_line.HasSwitch(switches::kFirstRun); - bool first_run_ui_bypass = false; + bool first_run_ui_bypass = false; // Initialize ResourceBundle which handles files loaded from external // sources. This has to be done before uninstall code path and before prefs @@ -339,7 +343,7 @@ int BrowserMain(CommandLine &parsed_command_line, int show_command, local_state->SetBoolean(prefs::kMetricsReportingEnabled, true); // On first run, we need to process the master preferences before the // browser's profile_manager object is created. - FirstRun::MasterPrefResult master_pref_res = + FirstRun::MasterPrefResult master_pref_res = FirstRun::ProcessMasterPreferences(user_data_dir, std::wstring()); first_run_ui_bypass = (master_pref_res == FirstRun::MASTER_PROFILE_NO_FIRST_RUN_UI); @@ -505,7 +509,7 @@ int BrowserMain(CommandLine &parsed_command_line, int show_command, ShellIntegration::VerifyInstallation(); browser_process->InitBrokerServices(broker_services); - + // In unittest mode, this will do nothing. In normal mode, this will create // the global GoogleURLTracker instance, which will promptly go to sleep for // five seconds (to avoid slowing startup), and wake up afterwards to see if @@ -544,10 +548,9 @@ int BrowserMain(CommandLine &parsed_command_line, int show_command, } metrics = browser_process->metrics_service(); DCHECK(metrics); - - // If we're testing then we don't care what the user - // preference is, we turn on recording, but not reporting, otherwise tests - // fail. + + // If we're testing then we don't care what the user preference is, we turn + // on recording, but not reporting, otherwise tests fail. if (parsed_command_line.HasSwitch(switches::kMetricsRecordingOnly)) { metrics->StartRecordingOnly(); } else { diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index 9ff0b7b..d4aabe7 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -5,9 +5,10 @@ #include "chrome/browser/browser_process_impl.h" #include "base/command_line.h" -#include "base/thread.h" #include "base/path_service.h" +#include "base/thread.h" #include "chrome/browser/automation/automation_provider_list.h" +#include "chrome/browser/browser_trial.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/download/download_file.h" #include "chrome/browser/download/save_file_manager.h" @@ -115,6 +116,16 @@ BrowserProcessImpl::BrowserProcessImpl(CommandLine& command_line) else if (model == L"medium") memory_model_ = MEDIUM_MEMORY_MODEL; } + } else { + // Randomly choose what memory model to use. + const double probability = 0.5; + FieldTrial* trial(new FieldTrial(BrowserTrial::kMemoryModelFieldTrial, + probability)); + DCHECK(FieldTrialList::Find(BrowserTrial::kMemoryModelFieldTrial) == trial); + if (trial->boolean_value()) + memory_model_ = HIGH_MEMORY_MODEL; + else + memory_model_ = MEDIUM_MEMORY_MODEL; } suspend_controller_ = new SuspendController(); diff --git a/chrome/browser/browser_trial.cc b/chrome/browser/browser_trial.cc new file mode 100644 index 0000000..16bfb18 --- /dev/null +++ b/chrome/browser/browser_trial.cc @@ -0,0 +1,8 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/browser_trial.h" + +// A test to determine the impact of using HIGH vs MEDIUM memory models. +const wchar_t* BrowserTrial::kMemoryModelFieldTrial = L"memory_model"; diff --git a/chrome/browser/browser_trial.h b/chrome/browser/browser_trial.h new file mode 100644 index 0000000..1752eba --- /dev/null +++ b/chrome/browser/browser_trial.h @@ -0,0 +1,22 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// BrowserTrial contains methods specific to field trials (using FieldTrial +// functionality) for browser tests. + +#ifndef CHROME_BROWSER_BROWSER_TRIAL_H_ +#define CHROME_BROWSER_BROWSER_TRIAL_H_ + +#include "base/field_trial.h" + +// Currently we use this as a name space, to hold static shared constants which +// define current and past trials. +class BrowserTrial { + public: + static const wchar_t* kMemoryModelFieldTrial; + private: + DISALLOW_COPY_AND_ASSIGN(BrowserTrial); +}; + +#endif // CHROME_BROWSER_BROWSER_TRIAL_H_ diff --git a/chrome/browser/render_widget_host_view_win.cc b/chrome/browser/render_widget_host_view_win.cc index 3788795..eef290f 100644 --- a/chrome/browser/render_widget_host_view_win.cc +++ b/chrome/browser/render_widget_host_view_win.cc @@ -11,6 +11,7 @@ #include "base/win_util.h" #include "chrome/browser/browser_accessibility.h" #include "chrome/browser/browser_accessibility_manager.h" +#include "chrome/browser/browser_trial.h" #include "chrome/browser/render_process_host.h" // TODO(beng): (Cleanup) we should not need to include this file... see comment // in |DidBecomeSelected|. @@ -433,7 +434,21 @@ void RenderWidgetHostViewWin::OnPaint(HDC dc) { } if (!whiteout_start_time_.is_null()) { TimeDelta whiteout_duration = TimeTicks::Now() - whiteout_start_time_; - UMA_HISTOGRAM_TIMES(L"MPArch.RWHH_WhiteoutDuration", whiteout_duration); + + // If field trial is active, report results in special histogram. + static scoped_refptr<FieldTrial> trial( + FieldTrialList::Find(BrowserTrial::kMemoryModelFieldTrial)); + if (trial.get()) { + if (trial->boolean_value()) + UMA_HISTOGRAM_TIMES(L"MPArch.RWHH_WhiteoutDuration_trial_high_memory", + whiteout_duration); + else + UMA_HISTOGRAM_TIMES(L"MPArch.RWHH_WhiteoutDuration_trial_med_memory", + whiteout_duration); + } else { + UMA_HISTOGRAM_TIMES(L"MPArch.RWHH_WhiteoutDuration", whiteout_duration); + } + // Reset the start time to 0 so that we start recording again the next // time the backing store is NULL... whiteout_start_time_ = TimeTicks(); |