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

Side by Side Diff: content/browser/browser_main_runner.cc

Issue 1359163004: Add Histograms to Measure Time in BrowserMainRunnerImpl::Initialize (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('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) 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 "content/public/browser/browser_main_runner.h" 5 #include "content/public/browser/browser_main_runner.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/leak_annotations.h" 9 #include "base/debug/leak_annotations.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/metrics/histogram_macros.h"
12 #include "base/metrics/statistics_recorder.h" 13 #include "base/metrics/statistics_recorder.h"
13 #include "base/profiler/scoped_profile.h" 14 #include "base/profiler/scoped_profile.h"
14 #include "base/profiler/scoped_tracker.h" 15 #include "base/profiler/scoped_tracker.h"
16 #include "base/time/time.h"
15 #include "base/trace_event/trace_event.h" 17 #include "base/trace_event/trace_event.h"
16 #include "base/tracked_objects.h" 18 #include "base/tracked_objects.h"
17 #include "components/tracing/trace_config_file.h" 19 #include "components/tracing/trace_config_file.h"
18 #include "components/tracing/tracing_switches.h" 20 #include "components/tracing/tracing_switches.h"
19 #include "content/browser/browser_main_loop.h" 21 #include "content/browser/browser_main_loop.h"
20 #include "content/browser/browser_shutdown_profile_dumper.h" 22 #include "content/browser/browser_shutdown_profile_dumper.h"
21 #include "content/browser/notification_service_impl.h" 23 #include "content/browser/notification_service_impl.h"
22 #include "content/public/browser/tracing_controller.h" 24 #include "content/public/browser/tracing_controller.h"
23 #include "content/public/common/content_switches.h" 25 #include "content/public/common/content_switches.h"
24 #include "content/public/common/main_function_params.h" 26 #include "content/public/common/main_function_params.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 public: 133 public:
132 BrowserMainRunnerImpl() 134 BrowserMainRunnerImpl()
133 : initialization_started_(false), is_shutdown_(false) {} 135 : initialization_started_(false), is_shutdown_(false) {}
134 136
135 ~BrowserMainRunnerImpl() override { 137 ~BrowserMainRunnerImpl() override {
136 if (initialization_started_ && !is_shutdown_) 138 if (initialization_started_ && !is_shutdown_)
137 Shutdown(); 139 Shutdown();
138 } 140 }
139 141
140 int Initialize(const MainFunctionParams& parameters) override { 142 int Initialize(const MainFunctionParams& parameters) override {
143 SCOPED_UMA_HISTOGRAM_LONG_TIMER(
144 "Startup.BrowserMainRunnerImplInitializeLongTime");
145
141 // TODO(vadimt, yiyaoliu): Remove all tracked_objects references below once 146 // TODO(vadimt, yiyaoliu): Remove all tracked_objects references below once
142 // crbug.com/453640 is fixed. 147 // crbug.com/453640 is fixed.
143 tracked_objects::ThreadData::InitializeThreadContext("CrBrowserMain"); 148 tracked_objects::ThreadData::InitializeThreadContext("CrBrowserMain");
144 TRACK_SCOPED_REGION( 149 TRACK_SCOPED_REGION(
145 "Startup", "BrowserMainRunnerImpl::Initialize"); 150 "Startup", "BrowserMainRunnerImpl::Initialize");
146 TRACE_EVENT0("startup", "BrowserMainRunnerImpl::Initialize"); 151 TRACE_EVENT0("startup", "BrowserMainRunnerImpl::Initialize");
147 152
148 // On Android we normally initialize the browser in a series of UI thread 153 // On Android we normally initialize the browser in a series of UI thread
149 // tasks. While this is happening a second request can come from the OS or 154 // tasks. While this is happening a second request can come from the OS or
150 // another application to start the browser. If this happens then we must 155 // another application to start the browser. If this happens then we must
151 // not run these parts of initialization twice. 156 // not run these parts of initialization twice.
ncarter (slow) 2015/09/23 16:34:19 This comment suggests that on Android, step2 might
robliao 2015/09/23 16:55:13 Agreed. My analysis currently excludes Android as
152 if (!initialization_started_) { 157 if (!initialization_started_) {
153 initialization_started_ = true; 158 initialization_started_ = true;
154 159
160 const base::TimeTicks start_time_step1 = base::TimeTicks::Now();
161
155 SkGraphics::Init(); 162 SkGraphics::Init();
156 163
157 #if !defined(OS_IOS) 164 #if !defined(OS_IOS)
158 if (parameters.command_line.HasSwitch(switches::kWaitForDebugger)) 165 if (parameters.command_line.HasSwitch(switches::kWaitForDebugger))
ncarter (slow) 2015/09/23 16:34:19 FYI, this may skew the results (though I expect it
robliao 2015/09/23 16:55:13 Good catch. I agree with the analysis and if we ha
159 base::debug::WaitForDebugger(60, true); 166 base::debug::WaitForDebugger(60, true);
160 #endif 167 #endif
161 168
162 #if defined(OS_WIN) 169 #if defined(OS_WIN)
163 if (base::win::GetVersion() < base::win::VERSION_VISTA) { 170 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
164 // When "Extend support of advanced text services to all programs" 171 // When "Extend support of advanced text services to all programs"
165 // (a.k.a. Cicero Unaware Application Support; CUAS) is enabled on 172 // (a.k.a. Cicero Unaware Application Support; CUAS) is enabled on
166 // Windows XP and handwriting modules shipped with Office 2003 are 173 // Windows XP and handwriting modules shipped with Office 2003 are
167 // installed, "penjpn.dll" and "skchui.dll" will be loaded and then 174 // installed, "penjpn.dll" and "skchui.dll" will be loaded and then
168 // crash unless a user installs Office 2003 SP3. To prevent these 175 // crash unless a user installs Office 2003 SP3. To prevent these
(...skipping 30 matching lines...) Expand all
199 206
200 main_loop_->PreMainMessageLoopStart(); 207 main_loop_->PreMainMessageLoopStart();
201 main_loop_->MainMessageLoopStart(); 208 main_loop_->MainMessageLoopStart();
202 main_loop_->PostMainMessageLoopStart(); 209 main_loop_->PostMainMessageLoopStart();
203 210
204 // WARNING: If we get a WM_ENDSESSION, objects created on the stack here 211 // WARNING: If we get a WM_ENDSESSION, objects created on the stack here
205 // are NOT deleted. If you need something to run during WM_ENDSESSION add it 212 // are NOT deleted. If you need something to run during WM_ENDSESSION add it
206 // to browser_shutdown::Shutdown or BrowserProcess::EndSession. 213 // to browser_shutdown::Shutdown or BrowserProcess::EndSession.
207 214
208 ui::InitializeInputMethod(); 215 ui::InitializeInputMethod();
216 UMA_HISTOGRAM_TIMES("Startup.BrowserMainRunnerImplInitializeStep1Time",
217 base::TimeTicks::Now() - start_time_step1);
209 } 218 }
219 const base::TimeTicks start_time_step2 = base::TimeTicks::Now();
210 main_loop_->CreateStartupTasks(); 220 main_loop_->CreateStartupTasks();
211 int result_code = main_loop_->GetResultCode(); 221 int result_code = main_loop_->GetResultCode();
212 if (result_code > 0) 222 if (result_code > 0)
213 return result_code; 223 return result_code;
214 224
225 UMA_HISTOGRAM_TIMES("Startup.BrowserMainRunnerImplInitializeStep2Time",
226 base::TimeTicks::Now() - start_time_step2);
227
215 // Return -1 to indicate no early termination. 228 // Return -1 to indicate no early termination.
216 return -1; 229 return -1;
217 } 230 }
218 231
219 int Run() override { 232 int Run() override {
220 DCHECK(initialization_started_); 233 DCHECK(initialization_started_);
221 DCHECK(!is_shutdown_); 234 DCHECK(!is_shutdown_);
222 main_loop_->RunMainMessageLoopParts(); 235 main_loop_->RunMainMessageLoopParts();
223 return main_loop_->GetResultCode(); 236 return main_loop_->GetResultCode();
224 } 237 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 BrowserMainRunner* BrowserMainRunner::Create() { 330 BrowserMainRunner* BrowserMainRunner::Create() {
318 return new BrowserMainRunnerImpl(); 331 return new BrowserMainRunnerImpl();
319 } 332 }
320 333
321 // static 334 // static
322 bool BrowserMainRunner::ExitedMainMessageLoop() { 335 bool BrowserMainRunner::ExitedMainMessageLoop() {
323 return g_exited_main_message_loop; 336 return g_exited_main_message_loop;
324 } 337 }
325 338
326 } // namespace content 339 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698