Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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. | |
| 253 base::TimeTicks StartupTimeToTimeTicks(const base::Time& time) { | 259 base::TimeTicks StartupTimeToTimeTicks(const base::Time& time) { |
| 254 // First get a base which represents the same point in time in both units. | 260 // 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 | 261 // Bump the priority of this thread while doing this as the wall clock time it |
| 256 // this method. | 262 // takes to resolve these two calls affects the precision of this method and |
| 263 // bumping the priority reduces the likelihood of a context switch interfering | |
| 264 // with this computation. | |
| 265 | |
| 266 // platform_thread_mac.mm unfortunately doesn't properly support base's | |
| 267 // thread priority APIs (crbug.com/554651). | |
| 268 #if !defined(OS_MACOSX) | |
| 269 static bool statics_initialized = false; | |
|
grt (UTC plus 2)
2016/09/17 09:22:06
Hi gang. The call to RecordExeMainEntryPointTime f
fdoray
2016/09/19 13:14:46
RecordStartupProcessCreationTime() takes a base::T
| |
| 270 | |
| 271 base::ThreadPriority previous_priority = base::ThreadPriority::NORMAL; | |
| 272 if (!statics_initialized) { | |
| 273 previous_priority = base::PlatformThread::GetCurrentThreadPriority(); | |
| 274 base::PlatformThread::SetCurrentThreadPriority( | |
| 275 base::ThreadPriority::DISPLAY); | |
| 276 } | |
| 277 #endif | |
| 278 | |
| 257 static const base::Time time_base = base::Time::Now(); | 279 static const base::Time time_base = base::Time::Now(); |
| 258 static const base::TimeTicks trace_ticks_base = base::TimeTicks::Now(); | 280 static const base::TimeTicks trace_ticks_base = base::TimeTicks::Now(); |
| 259 | 281 |
| 282 #if !defined(OS_MACOSX) | |
| 283 if (!statics_initialized) { | |
| 284 base::PlatformThread::SetCurrentThreadPriority(previous_priority); | |
| 285 } | |
| 286 | |
| 287 statics_initialized = true; | |
| 288 #endif | |
| 289 | |
| 260 // Then use the TimeDelta common ground between the two units to make the | 290 // Then use the TimeDelta common ground between the two units to make the |
| 261 // conversion. | 291 // conversion. |
| 262 const base::TimeDelta delta_since_base = time_base - time; | 292 const base::TimeDelta delta_since_base = time_base - time; |
| 263 return trace_ticks_base - delta_since_base; | 293 return trace_ticks_base - delta_since_base; |
| 264 } | 294 } |
| 265 | 295 |
| 266 // Record time of main entry so it can be read from Telemetry performance tests. | 296 // Record time of main entry so it can be read from Telemetry performance tests. |
| 267 // TODO(jeremy): Remove once crbug.com/317481 is fixed. | 297 // TODO(jeremy): Remove once crbug.com/317481 is fixed. |
| 268 void RecordMainEntryTimeHistogram() { | 298 void RecordMainEntryTimeHistogram() { |
| 269 const int kLowWordMask = 0xFFFFFFFF; | 299 const int kLowWordMask = 0xFFFFFFFF; |
| 270 const int kLower31BitsMask = 0x7FFFFFFF; | 300 const int kLower31BitsMask = 0x7FFFFFFF; |
| 271 DCHECK(!g_main_entry_point_time.Get().is_null()); | 301 DCHECK(!g_main_entry_point_time.Get().is_null()); |
| 272 base::TimeDelta browser_main_entry_time_absolute = | 302 const base::TimeDelta browser_main_entry_time_absolute = |
| 273 g_main_entry_point_time.Get() - base::Time::UnixEpoch(); | 303 g_main_entry_point_time.Get() - base::Time::UnixEpoch(); |
| 274 | 304 |
| 275 uint64 browser_main_entry_time_raw_ms = | 305 const uint64 browser_main_entry_time_raw_ms = |
| 276 browser_main_entry_time_absolute.InMilliseconds(); | 306 browser_main_entry_time_absolute.InMilliseconds(); |
| 277 | 307 |
| 278 base::TimeDelta browser_main_entry_time_raw_ms_high_word = | 308 const base::TimeDelta browser_main_entry_time_raw_ms_high_word = |
| 279 base::TimeDelta::FromMilliseconds( | 309 base::TimeDelta::FromMilliseconds( |
| 280 (browser_main_entry_time_raw_ms >> 32) & kLowWordMask); | 310 (browser_main_entry_time_raw_ms >> 32) & kLowWordMask); |
| 281 // Shift by one because histograms only support non-negative values. | 311 // Shift by one because histograms only support non-negative values. |
| 282 base::TimeDelta browser_main_entry_time_raw_ms_low_word = | 312 const base::TimeDelta browser_main_entry_time_raw_ms_low_word = |
| 283 base::TimeDelta::FromMilliseconds( | 313 base::TimeDelta::FromMilliseconds( |
| 284 (browser_main_entry_time_raw_ms >> 1) & kLower31BitsMask); | 314 (browser_main_entry_time_raw_ms >> 1) & kLower31BitsMask); |
| 285 | 315 |
| 286 // A timestamp is a 64 bit value, yet histograms can only store 32 bits. | 316 // A timestamp is a 64 bit value, yet histograms can only store 32 bits. |
| 287 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteHighWord", | 317 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteHighWord", |
| 288 browser_main_entry_time_raw_ms_high_word); | 318 browser_main_entry_time_raw_ms_high_word); |
| 289 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteLowWord", | 319 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteLowWord", |
| 290 browser_main_entry_time_raw_ms_low_word); | 320 browser_main_entry_time_raw_ms_low_word); |
| 291 } | 321 } |
| 292 | 322 |
| 293 // Environment variable that stores the timestamp when the executable's main() | 323 // Environment variable that stores the timestamp when the executable's main() |
| 294 // function was entered. | 324 // function was entered in TimeTicks. This is required because chrome.exe and |
| 295 const char kChromeMainTimeEnvVar[] = "CHROME_MAIN_TIME"; | 325 // chrome.dll don't share the same static storage. |
| 326 const char kChromeMainTicksEnvVar[] = "CHROME_MAIN_TICKS"; | |
| 296 | 327 |
| 297 // Returns the time of main entry recorded from RecordExeMainEntryTime. | 328 // Returns the time of main entry recorded from RecordExeMainEntryTime. |
| 298 base::Time ExeMainEntryPointTime() { | 329 base::TimeTicks ExeMainEntryPointTicks() { |
| 299 scoped_ptr<base::Environment> env(base::Environment::Create()); | 330 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 300 std::string time_string; | 331 std::string ticks_string; |
| 301 int64 time_int = 0; | 332 int64 time_int = 0; |
| 302 if (env->GetVar(kChromeMainTimeEnvVar, &time_string) && | 333 if (env->GetVar(kChromeMainTicksEnvVar, &ticks_string) && |
| 303 base::StringToInt64(time_string, &time_int)) { | 334 base::StringToInt64(ticks_string, &time_int)) { |
| 304 return base::Time::FromInternalValue(time_int); | 335 return base::TimeTicks::FromInternalValue(time_int); |
| 305 } | 336 } |
| 306 return base::Time(); | 337 return base::TimeTicks(); |
| 307 } | 338 } |
| 308 | 339 |
| 309 } // namespace | 340 } // namespace |
| 310 | 341 |
| 311 bool WasNonBrowserUIDisplayed() { | 342 bool WasNonBrowserUIDisplayed() { |
| 312 return g_non_browser_ui_displayed; | 343 return g_non_browser_ui_displayed; |
| 313 } | 344 } |
| 314 | 345 |
| 315 void SetNonBrowserUIDisplayed() { | 346 void SetNonBrowserUIDisplayed() { |
| 316 g_non_browser_ui_displayed = true; | 347 g_non_browser_ui_displayed = true; |
| 317 } | 348 } |
| 318 | 349 |
| 319 void RecordStartupProcessCreationTime(const base::Time& time) { | 350 void RecordStartupProcessCreationTime(const base::Time& time) { |
| 320 DCHECK(g_process_creation_time.Get().is_null()); | 351 DCHECK(g_process_creation_ticks.Get().is_null()); |
| 321 g_process_creation_time.Get() = time; | 352 g_process_creation_ticks.Get() = StartupTimeToTimeTicks(time); |
| 322 DCHECK(!g_process_creation_time.Get().is_null()); | 353 DCHECK(!g_process_creation_ticks.Get().is_null()); |
| 323 } | 354 } |
| 324 | 355 |
| 325 void RecordMainEntryPointTime(const base::Time& time) { | 356 void RecordMainEntryPointTime(const base::Time& time) { |
| 357 DCHECK(g_main_entry_point_ticks.Get().is_null()); | |
| 358 g_main_entry_point_ticks.Get() = StartupTimeToTimeTicks(time); | |
| 359 DCHECK(!g_main_entry_point_ticks.Get().is_null()); | |
| 360 | |
| 361 // TODO(jeremy): Remove this with RecordMainEntryTimeHistogram() when | |
| 362 // resolving crbug.com/317481. | |
| 326 DCHECK(g_main_entry_point_time.Get().is_null()); | 363 DCHECK(g_main_entry_point_time.Get().is_null()); |
| 327 g_main_entry_point_time.Get() = time; | 364 g_main_entry_point_time.Get() = time; |
| 328 DCHECK(!g_main_entry_point_time.Get().is_null()); | 365 DCHECK(!g_main_entry_point_time.Get().is_null()); |
| 329 } | 366 } |
| 330 | 367 |
| 331 void RecordExeMainEntryPointTime(const base::Time& time) { | 368 void RecordExeMainEntryPointTime(const base::Time& time) { |
| 332 std::string exe_load_time = base::Int64ToString(time.ToInternalValue()); | 369 const std::string exe_load_ticks = |
| 370 base::Int64ToString(StartupTimeToTimeTicks(time).ToInternalValue()); | |
| 333 scoped_ptr<base::Environment> env(base::Environment::Create()); | 371 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 334 env->SetVar(kChromeMainTimeEnvVar, exe_load_time); | 372 env->SetVar(kChromeMainTicksEnvVar, exe_load_ticks); |
| 335 } | 373 } |
| 336 | 374 |
| 337 void RecordBrowserMainMessageLoopStart(const base::Time& time, | 375 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, |
| 338 bool is_first_run) { | 376 bool is_first_run) { |
| 339 RecordHardFaultHistogram(is_first_run); | 377 RecordHardFaultHistogram(is_first_run); |
| 340 RecordMainEntryTimeHistogram(); | 378 RecordMainEntryTimeHistogram(); |
| 341 | 379 |
| 342 const base::Time& process_creation_time = g_process_creation_time.Get(); | 380 const base::TimeTicks& process_creation_ticks = |
| 343 if (!is_first_run && !process_creation_time.is_null()) { | 381 g_process_creation_ticks.Get(); |
| 382 if (!is_first_run && !process_creation_ticks.is_null()) { | |
| 344 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( | 383 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( |
| 345 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime", | 384 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime", |
| 346 process_creation_time, time); | 385 process_creation_ticks, ticks); |
| 347 } | 386 } |
| 348 | 387 |
| 349 // Bail if uptime < 7 minutes, to filter out cases where Chrome may have been | 388 // Bail if uptime < 7 minutes, to filter out cases where Chrome may have been |
| 350 // autostarted and the machine is under io pressure. | 389 // autostarted and the machine is under io pressure. |
| 351 if (base::SysInfo::Uptime() < base::TimeDelta::FromMinutes(7)) | 390 if (base::SysInfo::Uptime() < base::TimeDelta::FromMinutes(7)) |
| 352 return; | 391 return; |
| 353 | 392 |
| 354 // The Startup.BrowserMessageLoopStartTime histogram exhibits instability in | 393 // The Startup.BrowserMessageLoopStartTime histogram exhibits instability in |
| 355 // the field which limits its usefulness in all scenarios except when we have | 394 // 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: | 395 // 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. | 396 // * 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 | 397 // * 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. | 398 // cases where Chrome is auto-started and IO is heavily loaded. |
| 360 if (is_first_run) { | 399 if (is_first_run) { |
| 361 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( | 400 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( |
| 362 UMA_HISTOGRAM_LONG_TIMES, | 401 UMA_HISTOGRAM_LONG_TIMES, |
| 363 "Startup.BrowserMessageLoopStartTimeFromMainEntry.FirstRun", | 402 "Startup.BrowserMessageLoopStartTimeFromMainEntry.FirstRun", |
| 364 g_main_entry_point_time.Get(), time); | 403 g_main_entry_point_ticks.Get(), ticks); |
| 365 } else { | 404 } else { |
| 366 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( | 405 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( |
| 367 UMA_HISTOGRAM_LONG_TIMES, | 406 UMA_HISTOGRAM_LONG_TIMES, |
| 368 "Startup.BrowserMessageLoopStartTimeFromMainEntry", | 407 "Startup.BrowserMessageLoopStartTimeFromMainEntry", |
| 369 g_main_entry_point_time.Get(), time); | 408 g_main_entry_point_ticks.Get(), ticks); |
| 370 } | 409 } |
| 371 | 410 |
| 372 // Record timings between process creation, the main() in the executable being | 411 // Record timings between process creation, the main() in the executable being |
| 373 // reached and the main() in the shared library being reached. | 412 // reached and the main() in the shared library being reached. |
| 374 if (!process_creation_time.is_null()) { | 413 if (!process_creation_ticks.is_null()) { |
| 375 const base::Time exe_main_time = ExeMainEntryPointTime(); | 414 const base::TimeTicks exe_main_ticks = ExeMainEntryPointTicks(); |
| 376 if (!exe_main_time.is_null()) { | 415 if (!exe_main_ticks.is_null()) { |
| 377 // Process create to chrome.exe:main(). | 416 // Process create to chrome.exe:main(). |
| 378 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( | 417 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( |
| 379 UMA_HISTOGRAM_LONG_TIMES, "Startup.LoadTime.ProcessCreateToExeMain", | 418 UMA_HISTOGRAM_LONG_TIMES, "Startup.LoadTime.ProcessCreateToExeMain", |
| 380 process_creation_time, exe_main_time); | 419 process_creation_ticks, exe_main_ticks); |
| 381 | 420 |
| 382 // chrome.exe:main() to chrome.dll:main(). | 421 // chrome.exe:main() to chrome.dll:main(). |
| 383 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( | 422 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( |
| 384 UMA_HISTOGRAM_LONG_TIMES, "Startup.LoadTime.ExeMainToDllMain", | 423 UMA_HISTOGRAM_LONG_TIMES, "Startup.LoadTime.ExeMainToDllMain", |
| 385 exe_main_time, g_main_entry_point_time.Get()); | 424 exe_main_ticks, g_main_entry_point_ticks.Get()); |
| 386 | 425 |
| 387 // Process create to chrome.dll:main(). Reported as a histogram only as | 426 // Process create to chrome.dll:main(). Reported as a histogram only as |
| 388 // the other two events above are sufficient for tracing purposes. | 427 // the other two events above are sufficient for tracing purposes. |
| 389 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE( | 428 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE( |
| 390 UMA_HISTOGRAM_LONG_TIMES, "Startup.LoadTime.ProcessCreateToDllMain", | 429 UMA_HISTOGRAM_LONG_TIMES, "Startup.LoadTime.ProcessCreateToDllMain", |
| 391 g_main_entry_point_time.Get() - process_creation_time); | 430 g_main_entry_point_ticks.Get() - process_creation_ticks); |
| 392 } | 431 } |
| 393 } | 432 } |
| 394 } | 433 } |
| 395 | 434 |
| 396 void RecordBrowserWindowDisplay(const base::Time& time) { | 435 void RecordBrowserWindowDisplay(const base::TimeTicks& ticks) { |
| 397 static bool is_first_call = true; | 436 static bool is_first_call = true; |
| 398 if (!is_first_call || time.is_null()) | 437 if (!is_first_call || ticks.is_null()) |
| 399 return; | 438 return; |
| 400 is_first_call = false; | 439 is_first_call = false; |
| 401 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null()) | 440 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) |
| 402 return; | 441 return; |
| 403 | 442 |
| 404 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( | 443 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( |
| 405 UMA_HISTOGRAM_LONG_TIMES, "Startup.BrowserWindowDisplay", | 444 UMA_HISTOGRAM_LONG_TIMES, "Startup.BrowserWindowDisplay", |
| 406 g_process_creation_time.Get(), time); | 445 g_process_creation_ticks.Get(), ticks); |
| 407 } | 446 } |
| 408 | 447 |
| 409 void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta) { | 448 void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta) { |
| 410 static bool is_first_call = true; | 449 static bool is_first_call = true; |
| 411 if (!is_first_call) | 450 if (!is_first_call) |
| 412 return; | 451 return; |
| 413 is_first_call = false; | 452 is_first_call = false; |
| 414 | 453 |
| 415 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(UMA_HISTOGRAM_LONG_TIMES_100, | 454 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(UMA_HISTOGRAM_LONG_TIMES_100, |
| 416 "Startup.BrowserOpenTabs", delta); | 455 "Startup.BrowserOpenTabs", delta); |
| 417 } | 456 } |
| 418 | 457 |
| 419 void RecordFirstWebContentsMainFrameLoad(const base::Time& time) { | 458 void RecordFirstWebContentsMainFrameLoad(const base::TimeTicks& ticks) { |
| 420 static bool is_first_call = true; | 459 static bool is_first_call = true; |
| 421 if (!is_first_call || time.is_null()) | 460 if (!is_first_call || ticks.is_null()) |
| 422 return; | 461 return; |
| 423 is_first_call = false; | 462 is_first_call = false; |
| 424 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null()) | 463 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) |
| 425 return; | 464 return; |
| 426 | 465 |
| 427 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( | 466 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( |
| 428 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.MainFrameLoad2", | 467 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.MainFrameLoad2", |
| 429 g_process_creation_time.Get(), time); | 468 g_process_creation_ticks.Get(), ticks); |
| 430 } | 469 } |
| 431 | 470 |
| 432 void RecordDeprecatedFirstWebContentsMainFrameLoad(const base::Time& time) { | 471 void RecordDeprecatedFirstWebContentsMainFrameLoad( |
| 472 const base::TimeTicks& ticks) { | |
| 433 static bool is_first_call = true; | 473 static bool is_first_call = true; |
| 434 if (!is_first_call || time.is_null()) | 474 if (!is_first_call || ticks.is_null()) |
| 435 return; | 475 return; |
| 436 is_first_call = false; | 476 is_first_call = false; |
| 437 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null()) | 477 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) |
| 438 return; | 478 return; |
| 439 | 479 |
| 440 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE( | 480 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE( |
| 441 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.MainFrameLoad", | 481 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.MainFrameLoad", |
| 442 time - g_process_creation_time.Get()); | 482 ticks - g_process_creation_ticks.Get()); |
| 443 } | 483 } |
| 444 | 484 |
| 445 void RecordFirstWebContentsNonEmptyPaint(const base::Time& time) { | 485 void RecordFirstWebContentsNonEmptyPaint(const base::TimeTicks& ticks) { |
| 446 static bool is_first_call = true; | 486 static bool is_first_call = true; |
| 447 if (!is_first_call || time.is_null()) | 487 if (!is_first_call || ticks.is_null()) |
| 448 return; | 488 return; |
| 449 is_first_call = false; | 489 is_first_call = false; |
| 450 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null()) | 490 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) |
| 451 return; | 491 return; |
| 452 | 492 |
| 453 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( | 493 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( |
| 454 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint2", | 494 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint2", |
| 455 g_process_creation_time.Get(), time); | 495 g_process_creation_ticks.Get(), ticks); |
| 456 } | 496 } |
| 457 | 497 |
| 458 void RecordDeprecatedFirstWebContentsNonEmptyPaint(const base::Time& time) { | 498 void RecordDeprecatedFirstWebContentsNonEmptyPaint( |
| 499 const base::TimeTicks& ticks) { | |
| 459 static bool is_first_call = true; | 500 static bool is_first_call = true; |
| 460 if (!is_first_call || time.is_null()) | 501 if (!is_first_call || ticks.is_null()) |
| 461 return; | 502 return; |
| 462 is_first_call = false; | 503 is_first_call = false; |
| 463 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null()) | 504 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) |
| 464 return; | 505 return; |
| 465 | 506 |
| 466 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE( | 507 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE( |
| 467 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint", | 508 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint", |
| 468 time - g_process_creation_time.Get()); | 509 ticks - g_process_creation_ticks.Get()); |
| 469 } | 510 } |
| 470 | 511 |
| 471 void RecordFirstWebContentsMainNavigationStart(const base::Time& time) { | 512 void RecordFirstWebContentsMainNavigationStart(const base::TimeTicks& ticks) { |
| 472 static bool is_first_call = true; | 513 static bool is_first_call = true; |
| 473 if (!is_first_call || time.is_null()) | 514 if (!is_first_call || ticks.is_null()) |
| 474 return; | 515 return; |
| 475 is_first_call = false; | 516 is_first_call = false; |
| 476 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null()) | 517 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) |
| 477 return; | 518 return; |
| 478 | 519 |
| 479 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( | 520 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( |
| 480 UMA_HISTOGRAM_LONG_TIMES_100, | 521 UMA_HISTOGRAM_LONG_TIMES_100, |
| 481 "Startup.FirstWebContents.MainNavigationStart", | 522 "Startup.FirstWebContents.MainNavigationStart", |
| 482 g_process_creation_time.Get(), time); | 523 g_process_creation_ticks.Get(), ticks); |
| 483 } | 524 } |
| 484 | 525 |
| 485 void RecordFirstWebContentsMainNavigationFinished(const base::Time& time) { | 526 void RecordFirstWebContentsMainNavigationFinished( |
| 527 const base::TimeTicks& ticks) { | |
| 486 static bool is_first_call = true; | 528 static bool is_first_call = true; |
| 487 if (!is_first_call || time.is_null()) | 529 if (!is_first_call || ticks.is_null()) |
| 488 return; | 530 return; |
| 489 is_first_call = false; | 531 is_first_call = false; |
| 490 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null()) | 532 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) |
| 491 return; | 533 return; |
| 492 | 534 |
| 493 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( | 535 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( |
| 494 UMA_HISTOGRAM_LONG_TIMES_100, | 536 UMA_HISTOGRAM_LONG_TIMES_100, |
| 495 "Startup.FirstWebContents.MainNavigationFinished", | 537 "Startup.FirstWebContents.MainNavigationFinished", |
| 496 g_process_creation_time.Get(), time); | 538 g_process_creation_ticks.Get(), ticks); |
| 497 } | 539 } |
| 498 | 540 |
| 499 base::Time MainEntryPointTime() { | 541 base::TimeTicks MainEntryPointTicks() { |
| 500 return g_main_entry_point_time.Get(); | 542 return g_main_entry_point_ticks.Get(); |
| 501 } | 543 } |
| 502 | 544 |
| 503 StartupTemperature GetStartupTemperature() { | 545 StartupTemperature GetStartupTemperature() { |
| 504 return g_startup_temperature; | 546 return g_startup_temperature; |
| 505 } | 547 } |
| 506 | 548 |
| 507 } // namespace startup_metric_utils | 549 } // namespace startup_metric_utils |
| OLD | NEW |