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

Side by Side Diff: components/startup_metric_utils/browser/startup_metric_utils.cc

Issue 1425263003: Use TimeTicks as much as possible in startup_metric_utils. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "components/startup_metric_utils/browser/startup_metric_utils.h" 5 #include "components/startup_metric_utils/browser/startup_metric_utils.h"
6 6
7 #include "base/containers/hash_tables.h" 7 #include "base/containers/hash_tables.h"
8 #include "base/environment.h" 8 #include "base/environment.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/sys_info.h" 13 #include "base/sys_info.h"
14 #include "base/threading/platform_thread.h"
14 #include "base/trace_event/trace_event.h" 15 #include "base/trace_event/trace_event.h"
15 16
16 #if defined(OS_WIN) 17 #if defined(OS_WIN)
17 #include <winternl.h> 18 #include <winternl.h>
18 #include "base/win/windows_version.h" 19 #include "base/win/windows_version.h"
19 #endif 20 #endif
20 21
21 namespace startup_metric_utils { 22 namespace startup_metric_utils {
22 23
23 namespace { 24 namespace {
24 25
25 // Mark as volatile to defensively make sure usage is thread-safe. 26 // Mark as volatile to defensively make sure usage is thread-safe.
26 // Note that at the time of this writing, access is only on the UI thread. 27 // Note that at the time of this writing, access is only on the UI thread.
27 volatile bool g_non_browser_ui_displayed = false; 28 volatile bool g_non_browser_ui_displayed = false;
28 29
29 base::LazyInstance<base::Time>::Leaky g_process_creation_time = 30 base::LazyInstance<base::TimeTicks>::Leaky g_process_creation_ticks =
30 LAZY_INSTANCE_INITIALIZER; 31 LAZY_INSTANCE_INITIALIZER;
31 32
33 base::LazyInstance<base::TimeTicks>::Leaky g_main_entry_point_ticks =
34 LAZY_INSTANCE_INITIALIZER;
35
36 // Only used by RecordMainEntryTimeHistogram(), should go away with it (do not
37 // add new uses of this), see crbug.com/317481 for discussion on why it was kept
38 // as-is for now.
32 base::LazyInstance<base::Time>::Leaky g_main_entry_point_time = 39 base::LazyInstance<base::Time>::Leaky g_main_entry_point_time =
33 LAZY_INSTANCE_INITIALIZER; 40 LAZY_INSTANCE_INITIALIZER;
34 41
35 StartupTemperature g_startup_temperature = UNCERTAIN_STARTUP_TEMPERATURE; 42 StartupTemperature g_startup_temperature = UNCERTAIN_STARTUP_TEMPERATURE;
36 43
37 #if defined(OS_WIN) 44 #if defined(OS_WIN)
38 45
39 // These values are taken from the Startup.BrowserMessageLoopStartHardFaultCount 46 // These values are taken from the Startup.BrowserMessageLoopStartHardFaultCount
40 // histogram. If the cold start histogram starts looking strongly bimodal it may 47 // histogram. If the cold start histogram starts looking strongly bimodal it may
41 // be because the binary/resource sizes have grown significantly larger than 48 // be because the binary/resource sizes have grown significantly larger than
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 /* Always record to the base histogram. */ \ 176 /* Always record to the base histogram. */ \
170 type(basename, kValue); \ 177 type(basename, kValue); \
171 /* Record to the cold/warm suffixed histogram as appropriate. */ \ 178 /* Record to the cold/warm suffixed histogram as appropriate. */ \
172 if (g_startup_temperature == COLD_STARTUP_TEMPERATURE) { \ 179 if (g_startup_temperature == COLD_STARTUP_TEMPERATURE) { \
173 type(basename ".ColdStartup", kValue); \ 180 type(basename ".ColdStartup", kValue); \
174 } else if (g_startup_temperature == WARM_STARTUP_TEMPERATURE) { \ 181 } else if (g_startup_temperature == WARM_STARTUP_TEMPERATURE) { \
175 type(basename ".WarmStartup", kValue); \ 182 type(basename ".WarmStartup", kValue); \
176 } \ 183 } \
177 } 184 }
178 185
179 #define UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE(type, basename, \ 186 #define UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( \
180 begin_time, end_time) \ 187 type, basename, begin_ticks, end_ticks) \
181 { \ 188 { \
182 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(type, basename, \ 189 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(type, basename, \
183 end_time - begin_time) \ 190 end_ticks - begin_ticks) \
184 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( \ 191 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( \
185 "startup", basename, 0, \ 192 "startup", basename, 0, begin_ticks.ToInternalValue(), "Temperature", \
186 StartupTimeToTimeTicks(begin_time).ToInternalValue(), "Temperature", \ 193 g_startup_temperature); \
187 g_startup_temperature); \ 194 TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP1( \
188 TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP1( \ 195 "startup", basename, 0, end_ticks.ToInternalValue(), "Temperature", \
189 "startup", basename, 0, \ 196 g_startup_temperature); \
190 StartupTimeToTimeTicks(end_time).ToInternalValue(), "Temperature", \
191 g_startup_temperature); \
192 } 197 }
193 198
194 // On Windows, records the number of hard-faults that have occurred in the 199 // On Windows, records the number of hard-faults that have occurred in the
195 // current chrome.exe process since it was started. This is a nop on other 200 // current chrome.exe process since it was started. This is a nop on other
196 // platforms. 201 // platforms.
197 // crbug.com/476923 202 // crbug.com/476923
198 // TODO(chrisha): If this proves useful, use it to split startup stats in two. 203 // TODO(chrisha): If this proves useful, use it to split startup stats in two.
199 void RecordHardFaultHistogram(bool is_first_run) { 204 void RecordHardFaultHistogram(bool is_first_run) {
200 #if defined(OS_WIN) 205 #if defined(OS_WIN)
201 uint32_t hard_fault_count = 0; 206 uint32_t hard_fault_count = 0;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 g_startup_temperature = COLD_STARTUP_TEMPERATURE; 244 g_startup_temperature = COLD_STARTUP_TEMPERATURE;
240 } 245 }
241 246
242 // Record the startup 'temperature'. 247 // Record the startup 'temperature'.
243 UMA_HISTOGRAM_ENUMERATION( 248 UMA_HISTOGRAM_ENUMERATION(
244 "Startup.Temperature", g_startup_temperature, STARTUP_TEMPERATURE_MAX); 249 "Startup.Temperature", g_startup_temperature, STARTUP_TEMPERATURE_MAX);
245 #endif // defined(OS_WIN) 250 #endif // defined(OS_WIN)
246 } 251 }
247 252
248 // Converts a base::Time value to a base::TimeTicks value. The conversion isn't 253 // Converts a base::Time value to a base::TimeTicks value. The conversion isn't
249 // exact, but is within the time delta taken to synchronously resolve 254 // exact, but by capturing Time::Now() as early as possible, the likelihood of a
250 // base::Time::Now() and base::TimeTicks::Now() which in practice is pretty 255 // clock change between it and process start is as low as possible. There is
251 // much instant compared to multi-seconds startup timings. 256 // also the time taken to synchronously resolve base::Time::Now() and
252 // TODO(gab): Find a precise way to do this (http://crbug.com/544131). 257 // base::TimeTicks::Now() at play, but in practice it is pretty much instant
258 // compared to multi-seconds startup timings, especially since thread priority
259 // is temporarily increased to avoid this thread by descheduled between the two
fdoray 2015/11/09 21:27:16 this thread *to be* descheduled
gab 2015/11/10 01:25:29 Also re-worded (kept priority details for next com
260 // operations.
253 base::TimeTicks StartupTimeToTimeTicks(const base::Time& time) { 261 base::TimeTicks StartupTimeToTimeTicks(const base::Time& time) {
254 // First get a base which represents the same point in time in both units. 262 // First get a base which represents the same point in time in both units.
255 // The wall clock time it takes to gather both of these is the precision of 263 // Bump the priority of this thread while this is done as the wall clock time
256 // this method. 264 // it takes to resolve these two calls affects the precision of this method
265 // and bumping the priority reduces the likelihood of being descheduled.
266
fdoray 2015/11/09 21:27:16 // TODO(jeremy): Remove this when resolving crbug.
gab 2015/11/10 01:25:29 Why? This is used to only do the priority dance wh
267 static bool statics_initialized = false;
268
269 base::ThreadPriority previous_priority = base::ThreadPriority::NORMAL;
270 if (!statics_initialized) {
271 previous_priority = base::PlatformThread::GetCurrentThreadPriority();
272 base::PlatformThread::SetCurrentThreadPriority(
273 base::ThreadPriority::DISPLAY);
274 }
275
257 static const base::Time time_base = base::Time::Now(); 276 static const base::Time time_base = base::Time::Now();
258 static const base::TimeTicks trace_ticks_base = base::TimeTicks::Now(); 277 static const base::TimeTicks trace_ticks_base = base::TimeTicks::Now();
259 278
279 if (!statics_initialized) {
280 base::PlatformThread::SetCurrentThreadPriority(previous_priority);
281 }
282
283 statics_initialized = true;
284
260 // Then use the TimeDelta common ground between the two units to make the 285 // Then use the TimeDelta common ground between the two units to make the
261 // conversion. 286 // conversion.
262 const base::TimeDelta delta_since_base = time_base - time; 287 const base::TimeDelta delta_since_base = time_base - time;
263 return trace_ticks_base - delta_since_base; 288 return trace_ticks_base - delta_since_base;
264 } 289 }
265 290
266 // Record time of main entry so it can be read from Telemetry performance tests. 291 // Record time of main entry so it can be read from Telemetry performance tests.
267 // TODO(jeremy): Remove once crbug.com/317481 is fixed. 292 // TODO(jeremy): Remove once crbug.com/317481 is fixed.
268 void RecordMainEntryTimeHistogram() { 293 void RecordMainEntryTimeHistogram() {
269 const int kLowWordMask = 0xFFFFFFFF; 294 const int kLowWordMask = 0xFFFFFFFF;
270 const int kLower31BitsMask = 0x7FFFFFFF; 295 const int kLower31BitsMask = 0x7FFFFFFF;
271 DCHECK(!g_main_entry_point_time.Get().is_null()); 296 DCHECK(!g_main_entry_point_time.Get().is_null());
272 base::TimeDelta browser_main_entry_time_absolute = 297 const base::TimeDelta browser_main_entry_time_absolute =
273 g_main_entry_point_time.Get() - base::Time::UnixEpoch(); 298 g_main_entry_point_time.Get() - base::Time::UnixEpoch();
274 299
275 uint64 browser_main_entry_time_raw_ms = 300 const uint64 browser_main_entry_time_raw_ms =
276 browser_main_entry_time_absolute.InMilliseconds(); 301 browser_main_entry_time_absolute.InMilliseconds();
277 302
278 base::TimeDelta browser_main_entry_time_raw_ms_high_word = 303 const base::TimeDelta browser_main_entry_time_raw_ms_high_word =
279 base::TimeDelta::FromMilliseconds( 304 base::TimeDelta::FromMilliseconds(
280 (browser_main_entry_time_raw_ms >> 32) & kLowWordMask); 305 (browser_main_entry_time_raw_ms >> 32) & kLowWordMask);
281 // Shift by one because histograms only support non-negative values. 306 // Shift by one because histograms only support non-negative values.
282 base::TimeDelta browser_main_entry_time_raw_ms_low_word = 307 const base::TimeDelta browser_main_entry_time_raw_ms_low_word =
283 base::TimeDelta::FromMilliseconds( 308 base::TimeDelta::FromMilliseconds(
284 (browser_main_entry_time_raw_ms >> 1) & kLower31BitsMask); 309 (browser_main_entry_time_raw_ms >> 1) & kLower31BitsMask);
285 310
286 // A timestamp is a 64 bit value, yet histograms can only store 32 bits. 311 // A timestamp is a 64 bit value, yet histograms can only store 32 bits.
287 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteHighWord", 312 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteHighWord",
288 browser_main_entry_time_raw_ms_high_word); 313 browser_main_entry_time_raw_ms_high_word);
289 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteLowWord", 314 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteLowWord",
290 browser_main_entry_time_raw_ms_low_word); 315 browser_main_entry_time_raw_ms_low_word);
291 } 316 }
292 317
293 // Environment variable that stores the timestamp when the executable's main() 318 // Environment variable that stores the timestamp when the executable's main()
294 // function was entered. 319 // function was entered in TimeTicks.
295 const char kChromeMainTimeEnvVar[] = "CHROME_MAIN_TIME"; 320 const char kChromeMainTicksEnvVar[] = "CHROME_MAIN_TICKS";
296 321
297 // Returns the time of main entry recorded from RecordExeMainEntryTime. 322 // Returns the time of main entry recorded from RecordExeMainEntryTime.
298 base::Time ExeMainEntryPointTime() { 323 base::TimeTicks ExeMainEntryPointTicks() {
299 scoped_ptr<base::Environment> env(base::Environment::Create()); 324 scoped_ptr<base::Environment> env(base::Environment::Create());
300 std::string time_string; 325 std::string ticks_string;
301 int64 time_int = 0; 326 int64 time_int = 0;
302 if (env->GetVar(kChromeMainTimeEnvVar, &time_string) && 327 if (env->GetVar(kChromeMainTicksEnvVar, &ticks_string) &&
303 base::StringToInt64(time_string, &time_int)) { 328 base::StringToInt64(ticks_string, &time_int)) {
304 return base::Time::FromInternalValue(time_int); 329 return base::TimeTicks::FromInternalValue(time_int);
305 } 330 }
306 return base::Time(); 331 return base::TimeTicks();
307 } 332 }
308 333
309 } // namespace 334 } // namespace
310 335
311 bool WasNonBrowserUIDisplayed() { 336 bool WasNonBrowserUIDisplayed() {
312 return g_non_browser_ui_displayed; 337 return g_non_browser_ui_displayed;
313 } 338 }
314 339
315 void SetNonBrowserUIDisplayed() { 340 void SetNonBrowserUIDisplayed() {
316 g_non_browser_ui_displayed = true; 341 g_non_browser_ui_displayed = true;
317 } 342 }
318 343
319 void RecordStartupProcessCreationTime(const base::Time& time) { 344 void RecordStartupProcessCreationTime(const base::Time& time) {
320 DCHECK(g_process_creation_time.Get().is_null()); 345 DCHECK(g_process_creation_ticks.Get().is_null());
321 g_process_creation_time.Get() = time; 346 g_process_creation_ticks.Get() = StartupTimeToTimeTicks(time);
322 DCHECK(!g_process_creation_time.Get().is_null()); 347 DCHECK(!g_process_creation_ticks.Get().is_null());
323 } 348 }
324 349
325 void RecordMainEntryPointTime(const base::Time& time) { 350 void RecordMainEntryPointTime(const base::Time& time) {
351 DCHECK(g_main_entry_point_ticks.Get().is_null());
352 g_main_entry_point_ticks.Get() = StartupTimeToTimeTicks(time);
353 DCHECK(!g_main_entry_point_ticks.Get().is_null());
354
355 // TODO(jeremy): Remove this with RecordMainEntryTimeHistogram() when
356 // resolving crbug.com/317481.
326 DCHECK(g_main_entry_point_time.Get().is_null()); 357 DCHECK(g_main_entry_point_time.Get().is_null());
327 g_main_entry_point_time.Get() = time; 358 g_main_entry_point_time.Get() = time;
328 DCHECK(!g_main_entry_point_time.Get().is_null()); 359 DCHECK(!g_main_entry_point_time.Get().is_null());
329 } 360 }
330 361
331 void RecordExeMainEntryPointTime(const base::Time& time) { 362 void RecordExeMainEntryPointTime(const base::Time& time) {
332 std::string exe_load_time = base::Int64ToString(time.ToInternalValue()); 363 const std::string exe_load_ticks =
364 base::Int64ToString(StartupTimeToTimeTicks(time).ToInternalValue());
333 scoped_ptr<base::Environment> env(base::Environment::Create()); 365 scoped_ptr<base::Environment> env(base::Environment::Create());
334 env->SetVar(kChromeMainTimeEnvVar, exe_load_time); 366 env->SetVar(kChromeMainTicksEnvVar, exe_load_ticks);
fdoray 2015/11/09 21:27:16 It might be good to explain that we need an enviro
gab 2015/11/10 01:25:29 Done.
335 } 367 }
336 368
337 void RecordBrowserMainMessageLoopStart(const base::Time& time, 369 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks,
338 bool is_first_run) { 370 bool is_first_run) {
339 RecordHardFaultHistogram(is_first_run); 371 RecordHardFaultHistogram(is_first_run);
340 RecordMainEntryTimeHistogram(); 372 RecordMainEntryTimeHistogram();
341 373
342 const base::Time& process_creation_time = g_process_creation_time.Get(); 374 const base::TimeTicks& process_creation_ticks =
343 if (!is_first_run && !process_creation_time.is_null()) { 375 g_process_creation_ticks.Get();
376 if (!is_first_run && !process_creation_ticks.is_null()) {
344 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( 377 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE(
345 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime", 378 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime",
346 process_creation_time, time); 379 process_creation_ticks, ticks);
347 } 380 }
348 381
349 // Bail if uptime < 7 minutes, to filter out cases where Chrome may have been 382 // Bail if uptime < 7 minutes, to filter out cases where Chrome may have been
350 // autostarted and the machine is under io pressure. 383 // autostarted and the machine is under io pressure.
351 if (base::SysInfo::Uptime() < base::TimeDelta::FromMinutes(7)) 384 if (base::SysInfo::Uptime() < base::TimeDelta::FromMinutes(7))
352 return; 385 return;
353 386
354 // The Startup.BrowserMessageLoopStartTime histogram exhibits instability in 387 // The Startup.BrowserMessageLoopStartTime histogram exhibits instability in
355 // the field which limits its usefulness in all scenarios except when we have 388 // the field which limits its usefulness in all scenarios except when we have
356 // a very large sample size. Attempt to mitigate this with a new metric: 389 // a very large sample size. Attempt to mitigate this with a new metric:
357 // * Measure time from main entry rather than the OS' notion of process start. 390 // * Measure time from main entry rather than the OS' notion of process start.
358 // * Only measure launches that occur 7 minutes after boot to try to avoid 391 // * Only measure launches that occur 7 minutes after boot to try to avoid
359 // cases where Chrome is auto-started and IO is heavily loaded. 392 // cases where Chrome is auto-started and IO is heavily loaded.
360 if (is_first_run) { 393 if (is_first_run) {
361 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( 394 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE(
362 UMA_HISTOGRAM_LONG_TIMES, 395 UMA_HISTOGRAM_LONG_TIMES,
363 "Startup.BrowserMessageLoopStartTimeFromMainEntry.FirstRun", 396 "Startup.BrowserMessageLoopStartTimeFromMainEntry.FirstRun",
364 g_main_entry_point_time.Get(), time); 397 g_main_entry_point_ticks.Get(), ticks);
365 } else { 398 } else {
366 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( 399 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE(
367 UMA_HISTOGRAM_LONG_TIMES, 400 UMA_HISTOGRAM_LONG_TIMES,
368 "Startup.BrowserMessageLoopStartTimeFromMainEntry", 401 "Startup.BrowserMessageLoopStartTimeFromMainEntry",
369 g_main_entry_point_time.Get(), time); 402 g_main_entry_point_ticks.Get(), ticks);
370 } 403 }
371 404
372 // Record timings between process creation, the main() in the executable being 405 // Record timings between process creation, the main() in the executable being
373 // reached and the main() in the shared library being reached. 406 // reached and the main() in the shared library being reached.
374 if (!process_creation_time.is_null()) { 407 if (!process_creation_ticks.is_null()) {
375 const base::Time exe_main_time = ExeMainEntryPointTime(); 408 const base::TimeTicks exe_main_ticks = ExeMainEntryPointTicks();
376 if (!exe_main_time.is_null()) { 409 if (!exe_main_ticks.is_null()) {
377 // Process create to chrome.exe:main(). 410 // Process create to chrome.exe:main().
378 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( 411 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE(
379 UMA_HISTOGRAM_LONG_TIMES, "Startup.LoadTime.ProcessCreateToExeMain", 412 UMA_HISTOGRAM_LONG_TIMES, "Startup.LoadTime.ProcessCreateToExeMain",
380 process_creation_time, exe_main_time); 413 process_creation_ticks, exe_main_ticks);
381 414
382 // chrome.exe:main() to chrome.dll:main(). 415 // chrome.exe:main() to chrome.dll:main().
383 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( 416 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE(
384 UMA_HISTOGRAM_LONG_TIMES, "Startup.LoadTime.ExeMainToDllMain", 417 UMA_HISTOGRAM_LONG_TIMES, "Startup.LoadTime.ExeMainToDllMain",
385 exe_main_time, g_main_entry_point_time.Get()); 418 exe_main_ticks, g_main_entry_point_ticks.Get());
386 419
387 // Process create to chrome.dll:main(). Reported as a histogram only as 420 // Process create to chrome.dll:main(). Reported as a histogram only as
388 // the other two events above are sufficient for tracing purposes. 421 // the other two events above are sufficient for tracing purposes.
389 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE( 422 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(
390 UMA_HISTOGRAM_LONG_TIMES, "Startup.LoadTime.ProcessCreateToDllMain", 423 UMA_HISTOGRAM_LONG_TIMES, "Startup.LoadTime.ProcessCreateToDllMain",
391 g_main_entry_point_time.Get() - process_creation_time); 424 g_main_entry_point_ticks.Get() - process_creation_ticks);
392 } 425 }
393 } 426 }
394 } 427 }
395 428
396 void RecordBrowserWindowDisplay(const base::Time& time) { 429 void RecordBrowserWindowDisplay(const base::TimeTicks& ticks) {
397 static bool is_first_call = true; 430 static bool is_first_call = true;
398 if (!is_first_call || time.is_null()) 431 if (!is_first_call || ticks.is_null())
399 return; 432 return;
400 is_first_call = false; 433 is_first_call = false;
401 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null()) 434 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null())
402 return; 435 return;
403 436
404 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( 437 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE(
405 UMA_HISTOGRAM_LONG_TIMES, "Startup.BrowserWindowDisplay", 438 UMA_HISTOGRAM_LONG_TIMES, "Startup.BrowserWindowDisplay",
406 g_process_creation_time.Get(), time); 439 g_process_creation_ticks.Get(), ticks);
407 } 440 }
408 441
409 void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta) { 442 void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta) {
410 static bool is_first_call = true; 443 static bool is_first_call = true;
411 if (!is_first_call) 444 if (!is_first_call)
412 return; 445 return;
413 is_first_call = false; 446 is_first_call = false;
414 447
415 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(UMA_HISTOGRAM_LONG_TIMES_100, 448 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(UMA_HISTOGRAM_LONG_TIMES_100,
416 "Startup.BrowserOpenTabs", delta); 449 "Startup.BrowserOpenTabs", delta);
417 } 450 }
418 451
419 void RecordFirstWebContentsMainFrameLoad(const base::Time& time) { 452 void RecordFirstWebContentsMainFrameLoad(const base::TimeTicks& ticks) {
420 static bool is_first_call = true; 453 static bool is_first_call = true;
421 if (!is_first_call || time.is_null()) 454 if (!is_first_call || ticks.is_null())
422 return; 455 return;
423 is_first_call = false; 456 is_first_call = false;
424 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null()) 457 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null())
425 return; 458 return;
426 459
427 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( 460 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE(
428 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.MainFrameLoad2", 461 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.MainFrameLoad2",
429 g_process_creation_time.Get(), time); 462 g_process_creation_ticks.Get(), ticks);
430 } 463 }
431 464
432 void RecordDeprecatedFirstWebContentsMainFrameLoad(const base::Time& time) { 465 void RecordDeprecatedFirstWebContentsMainFrameLoad(
466 const base::TimeTicks& ticks) {
433 static bool is_first_call = true; 467 static bool is_first_call = true;
434 if (!is_first_call || time.is_null()) 468 if (!is_first_call || ticks.is_null())
435 return; 469 return;
436 is_first_call = false; 470 is_first_call = false;
437 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null()) 471 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null())
438 return; 472 return;
439 473
440 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE( 474 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(
441 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.MainFrameLoad", 475 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.MainFrameLoad",
442 time - g_process_creation_time.Get()); 476 ticks - g_process_creation_ticks.Get());
443 } 477 }
444 478
445 void RecordFirstWebContentsNonEmptyPaint(const base::Time& time) { 479 void RecordFirstWebContentsNonEmptyPaint(const base::TimeTicks& ticks) {
446 static bool is_first_call = true; 480 static bool is_first_call = true;
447 if (!is_first_call || time.is_null()) 481 if (!is_first_call || ticks.is_null())
448 return; 482 return;
449 is_first_call = false; 483 is_first_call = false;
450 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null()) 484 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null())
451 return; 485 return;
452 486
453 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( 487 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE(
454 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint2", 488 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint2",
455 g_process_creation_time.Get(), time); 489 g_process_creation_ticks.Get(), ticks);
456 } 490 }
457 491
458 void RecordDeprecatedFirstWebContentsNonEmptyPaint(const base::Time& time) { 492 void RecordDeprecatedFirstWebContentsNonEmptyPaint(
493 const base::TimeTicks& ticks) {
459 static bool is_first_call = true; 494 static bool is_first_call = true;
460 if (!is_first_call || time.is_null()) 495 if (!is_first_call || ticks.is_null())
461 return; 496 return;
462 is_first_call = false; 497 is_first_call = false;
463 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null()) 498 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null())
464 return; 499 return;
465 500
466 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE( 501 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(
467 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint", 502 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint",
468 time - g_process_creation_time.Get()); 503 ticks - g_process_creation_ticks.Get());
469 } 504 }
470 505
471 void RecordFirstWebContentsMainNavigationStart(const base::Time& time) { 506 void RecordFirstWebContentsMainNavigationStart(const base::TimeTicks& ticks) {
472 static bool is_first_call = true; 507 static bool is_first_call = true;
473 if (!is_first_call || time.is_null()) 508 if (!is_first_call || ticks.is_null())
474 return; 509 return;
475 is_first_call = false; 510 is_first_call = false;
476 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null()) 511 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null())
477 return; 512 return;
478 513
479 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( 514 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE(
480 UMA_HISTOGRAM_LONG_TIMES_100, 515 UMA_HISTOGRAM_LONG_TIMES_100,
481 "Startup.FirstWebContents.MainNavigationStart", 516 "Startup.FirstWebContents.MainNavigationStart",
482 g_process_creation_time.Get(), time); 517 g_process_creation_ticks.Get(), ticks);
483 } 518 }
484 519
485 void RecordFirstWebContentsMainNavigationFinished(const base::Time& time) { 520 void RecordFirstWebContentsMainNavigationFinished(
521 const base::TimeTicks& ticks) {
486 static bool is_first_call = true; 522 static bool is_first_call = true;
487 if (!is_first_call || time.is_null()) 523 if (!is_first_call || ticks.is_null())
488 return; 524 return;
489 is_first_call = false; 525 is_first_call = false;
490 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null()) 526 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null())
491 return; 527 return;
492 528
493 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( 529 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE(
494 UMA_HISTOGRAM_LONG_TIMES_100, 530 UMA_HISTOGRAM_LONG_TIMES_100,
495 "Startup.FirstWebContents.MainNavigationFinished", 531 "Startup.FirstWebContents.MainNavigationFinished",
496 g_process_creation_time.Get(), time); 532 g_process_creation_ticks.Get(), ticks);
497 } 533 }
498 534
499 StartupTemperature GetStartupTemperature() { 535 StartupTemperature GetStartupTemperature() {
500 return g_startup_temperature; 536 return g_startup_temperature;
501 } 537 }
502 538
503 } // namespace startup_metric_utils 539 } // namespace startup_metric_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698