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" |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 | 307 |
| 308 const base::TimeDelta browser_main_entry_time_raw_ms_high_word = | 308 const base::TimeDelta browser_main_entry_time_raw_ms_high_word = |
| 309 base::TimeDelta::FromMilliseconds( | 309 base::TimeDelta::FromMilliseconds( |
| 310 (browser_main_entry_time_raw_ms >> 32) & kLowWordMask); | 310 (browser_main_entry_time_raw_ms >> 32) & kLowWordMask); |
| 311 // Shift by one because histograms only support non-negative values. | 311 // Shift by one because histograms only support non-negative values. |
| 312 const base::TimeDelta browser_main_entry_time_raw_ms_low_word = | 312 const base::TimeDelta browser_main_entry_time_raw_ms_low_word = |
| 313 base::TimeDelta::FromMilliseconds( | 313 base::TimeDelta::FromMilliseconds( |
| 314 (browser_main_entry_time_raw_ms >> 1) & kLower31BitsMask); | 314 (browser_main_entry_time_raw_ms >> 1) & kLower31BitsMask); |
| 315 | 315 |
| 316 // 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. |
| 317 // TODO(gabadie): Once startup_with_url.* benchmarks are replaced by | |
|
gab
2015/11/12 14:41:38
Please add bug#
gabadie
2015/11/12 17:43:34
Done.
| |
| 318 // startup_with_url2.*, remove this dirty hack. | |
| 317 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteHighWord", | 319 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteHighWord", |
| 318 browser_main_entry_time_raw_ms_high_word); | 320 browser_main_entry_time_raw_ms_high_word); |
| 319 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteLowWord", | 321 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteLowWord", |
| 320 browser_main_entry_time_raw_ms_low_word); | 322 browser_main_entry_time_raw_ms_low_word); |
| 321 } | 323 } |
| 322 | 324 |
| 323 // Environment variable that stores the timestamp when the executable's main() | 325 // Environment variable that stores the timestamp when the executable's main() |
| 324 // function was entered in TimeTicks. This is required because chrome.exe and | 326 // function was entered in TimeTicks. This is required because chrome.exe and |
| 325 // chrome.dll don't share the same static storage. | 327 // chrome.dll don't share the same static storage. |
| 326 const char kChromeMainTicksEnvVar[] = "CHROME_MAIN_TICKS"; | 328 const char kChromeMainTicksEnvVar[] = "CHROME_MAIN_TICKS"; |
| 327 | 329 |
| 328 // Returns the time of main entry recorded from RecordExeMainEntryTime. | 330 // Returns the time of main entry recorded from RecordExeMainEntryTime. |
| 329 base::TimeTicks ExeMainEntryPointTicks() { | 331 base::TimeTicks ExeMainEntryPointTicks() { |
| 330 scoped_ptr<base::Environment> env(base::Environment::Create()); | 332 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 331 std::string ticks_string; | 333 std::string ticks_string; |
| 332 int64 time_int = 0; | 334 int64 time_int = 0; |
| 333 if (env->GetVar(kChromeMainTicksEnvVar, &ticks_string) && | 335 if (env->GetVar(kChromeMainTicksEnvVar, &ticks_string) && |
| 334 base::StringToInt64(ticks_string, &time_int)) { | 336 base::StringToInt64(ticks_string, &time_int)) { |
| 335 return base::TimeTicks::FromInternalValue(time_int); | 337 return base::TimeTicks::FromInternalValue(time_int); |
| 336 } | 338 } |
| 337 return base::TimeTicks(); | 339 return base::TimeTicks(); |
| 338 } | 340 } |
| 339 | 341 |
| 342 // Records "instant" trace events for global timings observed by telemetry. | |
| 343 void AddStartupEventsForTelemetry() { | |
| 344 DCHECK(!g_process_creation_ticks.Get().is_null()); | |
| 345 DCHECK(!g_main_entry_point_ticks.Get().is_null()); | |
| 346 | |
| 347 TRACE_EVENT_INSTANT_WITH_TIMESTAMP( | |
| 348 "startup", "Startup.BrowserProcessCreation", 0, | |
| 349 g_process_creation_ticks.Get().ToInternalValue()); | |
| 350 | |
| 351 TRACE_EVENT_INSTANT_WITH_TIMESTAMP( | |
| 352 "startup", "Startup.BrowserMainEntryPoint", 0, | |
| 353 g_main_entry_point_ticks.Get().ToInternalValue()); | |
| 354 } | |
|
gab
2015/11/12 14:41:38
Also, FYI going forward, I think telemetry should
gabadie
2015/11/12 17:43:33
Telemetry w'll use thoses values to diff to other
| |
| 355 | |
| 340 } // namespace | 356 } // namespace |
| 341 | 357 |
| 342 bool WasNonBrowserUIDisplayed() { | 358 bool WasNonBrowserUIDisplayed() { |
| 343 return g_non_browser_ui_displayed; | 359 return g_non_browser_ui_displayed; |
| 344 } | 360 } |
| 345 | 361 |
| 346 void SetNonBrowserUIDisplayed() { | 362 void SetNonBrowserUIDisplayed() { |
| 347 g_non_browser_ui_displayed = true; | 363 g_non_browser_ui_displayed = true; |
| 348 } | 364 } |
| 349 | 365 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 367 | 383 |
| 368 void RecordExeMainEntryPointTime(const base::Time& time) { | 384 void RecordExeMainEntryPointTime(const base::Time& time) { |
| 369 const std::string exe_load_ticks = | 385 const std::string exe_load_ticks = |
| 370 base::Int64ToString(StartupTimeToTimeTicks(time).ToInternalValue()); | 386 base::Int64ToString(StartupTimeToTimeTicks(time).ToInternalValue()); |
| 371 scoped_ptr<base::Environment> env(base::Environment::Create()); | 387 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 372 env->SetVar(kChromeMainTicksEnvVar, exe_load_ticks); | 388 env->SetVar(kChromeMainTicksEnvVar, exe_load_ticks); |
| 373 } | 389 } |
| 374 | 390 |
| 375 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, | 391 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, |
| 376 bool is_first_run) { | 392 bool is_first_run) { |
| 393 AddStartupEventsForTelemetry(); | |
| 377 RecordHardFaultHistogram(is_first_run); | 394 RecordHardFaultHistogram(is_first_run); |
| 378 RecordMainEntryTimeHistogram(); | 395 RecordMainEntryTimeHistogram(); |
| 379 | 396 |
| 380 const base::TimeTicks& process_creation_ticks = | 397 const base::TimeTicks& process_creation_ticks = |
| 381 g_process_creation_ticks.Get(); | 398 g_process_creation_ticks.Get(); |
| 382 if (!is_first_run && !process_creation_ticks.is_null()) { | 399 if (!is_first_run && !process_creation_ticks.is_null()) { |
| 383 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( | 400 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( |
| 384 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime", | 401 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime", |
| 385 process_creation_ticks, ticks); | 402 process_creation_ticks, ticks); |
| 386 } | 403 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 | 557 |
| 541 base::TimeTicks MainEntryPointTicks() { | 558 base::TimeTicks MainEntryPointTicks() { |
| 542 return g_main_entry_point_ticks.Get(); | 559 return g_main_entry_point_ticks.Get(); |
| 543 } | 560 } |
| 544 | 561 |
| 545 StartupTemperature GetStartupTemperature() { | 562 StartupTemperature GetStartupTemperature() { |
| 546 return g_startup_temperature; | 563 return g_startup_temperature; |
| 547 } | 564 } |
| 548 | 565 |
| 549 } // namespace startup_metric_utils | 566 } // namespace startup_metric_utils |
| OLD | NEW |