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

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

Issue 1413533008: Add UMA metric: Startup.BrowserMainToRendererMain. (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"
(...skipping 11 matching lines...) Expand all
22 22
23 namespace { 23 namespace {
24 24
25 // Mark as volatile to defensively make sure usage is thread-safe. 25 // 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. 26 // Note that at the time of this writing, access is only on the UI thread.
27 volatile bool g_non_browser_ui_displayed = false; 27 volatile bool g_non_browser_ui_displayed = false;
28 28
29 base::LazyInstance<base::Time>::Leaky g_process_creation_time = 29 base::LazyInstance<base::Time>::Leaky g_process_creation_time =
30 LAZY_INSTANCE_INITIALIZER; 30 LAZY_INSTANCE_INITIALIZER;
31 31
32 base::LazyInstance<base::Time>::Leaky g_main_entry_point_time = 32 base::LazyInstance<base::Time>::Leaky g_browser_main_entry_point_time =
33 LAZY_INSTANCE_INITIALIZER;
34
35 base::LazyInstance<base::Time>::Leaky g_renderer_main_entry_point_time =
33 LAZY_INSTANCE_INITIALIZER; 36 LAZY_INSTANCE_INITIALIZER;
34 37
35 StartupTemperature g_startup_temperature = UNCERTAIN_STARTUP_TEMPERATURE; 38 StartupTemperature g_startup_temperature = UNCERTAIN_STARTUP_TEMPERATURE;
36 39
37 #if defined(OS_WIN) 40 #if defined(OS_WIN)
38 41
39 // These values are taken from the Startup.BrowserMessageLoopStartHardFaultCount 42 // These values are taken from the Startup.BrowserMessageLoopStartHardFaultCount
40 // histogram. If the cold start histogram starts looking strongly bimodal it may 43 // histogram. If the cold start histogram starts looking strongly bimodal it may
41 // be because the binary/resource sizes have grown significantly larger than 44 // be because the binary/resource sizes have grown significantly larger than
42 // when these values were set. In this case the new values need to be chosen 45 // when these values were set. In this case the new values need to be chosen
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 base::TimeDelta::FromMilliseconds( 286 base::TimeDelta::FromMilliseconds(
284 (browser_main_entry_time_raw_ms >> 1) & kLower31BitsMask); 287 (browser_main_entry_time_raw_ms >> 1) & kLower31BitsMask);
285 288
286 // A timestamp is a 64 bit value, yet histograms can only store 32 bits. 289 // A timestamp is a 64 bit value, yet histograms can only store 32 bits.
287 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteHighWord", 290 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteHighWord",
288 browser_main_entry_time_raw_ms_high_word); 291 browser_main_entry_time_raw_ms_high_word);
289 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteLowWord", 292 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteLowWord",
290 browser_main_entry_time_raw_ms_low_word); 293 browser_main_entry_time_raw_ms_low_word);
291 } 294 }
292 295
296 // Record renderer main entry time histogram.
297 void RecordRendererMainEntryHistogram() {
298 const base::Time& browser_main_entry_point_time =
299 g_browser_main_entry_point_time.Get();
300 const base::Time& renderer_main_entry_point_time =
301 g_renderer_main_entry_point_time.Get();
302
303 if (!browser_main_entry_point_time.is_null() &&
304 !renderer_main_entry_point_time.is_null()) {
305 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE(
306 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserDLLMainToRendererDLLMain",
307 browser_main_entry_point_time, renderer_main_entry_point_time);
308 }
309 }
310
293 // Environment variable that stores the timestamp when the executable's main() 311 // Environment variable that stores the timestamp when the executable's main()
294 // function was entered. 312 // function was entered.
295 const char kChromeMainTimeEnvVar[] = "CHROME_MAIN_TIME"; 313 const char kChromeMainTimeEnvVar[] = "CHROME_MAIN_TIME";
296 314
297 // Returns the time of main entry recorded from RecordExeMainEntryTime. 315 // Returns the time of main entry recorded from RecordExeMainEntryTime.
298 base::Time ExeMainEntryPointTime() { 316 base::Time ExeMainEntryPointTime() {
299 scoped_ptr<base::Environment> env(base::Environment::Create()); 317 scoped_ptr<base::Environment> env(base::Environment::Create());
300 std::string time_string; 318 std::string time_string;
301 int64 time_int = 0; 319 int64 time_int = 0;
302 if (env->GetVar(kChromeMainTimeEnvVar, &time_string) && 320 if (env->GetVar(kChromeMainTimeEnvVar, &time_string) &&
(...skipping 14 matching lines...) Expand all
317 } 335 }
318 336
319 void RecordStartupProcessCreationTime(const base::Time& time) { 337 void RecordStartupProcessCreationTime(const base::Time& time) {
320 DCHECK(g_process_creation_time.Get().is_null()); 338 DCHECK(g_process_creation_time.Get().is_null());
321 g_process_creation_time.Get() = time; 339 g_process_creation_time.Get() = time;
322 DCHECK(!g_process_creation_time.Get().is_null()); 340 DCHECK(!g_process_creation_time.Get().is_null());
323 } 341 }
324 342
325 void RecordMainEntryPointTime(const base::Time& time) { 343 void RecordMainEntryPointTime(const base::Time& time) {
326 DCHECK(MainEntryPointTime().is_null()); 344 DCHECK(MainEntryPointTime().is_null());
327 g_main_entry_point_time.Get() = time; 345 g_browser_main_entry_point_time.Get() = time;
328 DCHECK(!MainEntryPointTime().is_null()); 346 DCHECK(!MainEntryPointTime().is_null());
329 } 347 }
330 348
331 void RecordExeMainEntryPointTime(const base::Time& time) { 349 void RecordExeMainEntryPointTime(const base::Time& time) {
332 std::string exe_load_time = base::Int64ToString(time.ToInternalValue()); 350 std::string exe_load_time = base::Int64ToString(time.ToInternalValue());
333 scoped_ptr<base::Environment> env(base::Environment::Create()); 351 scoped_ptr<base::Environment> env(base::Environment::Create());
334 env->SetVar(kChromeMainTimeEnvVar, exe_load_time); 352 env->SetVar(kChromeMainTimeEnvVar, exe_load_time);
335 } 353 }
336 354
337 void RecordBrowserMainMessageLoopStart(const base::Time& time, 355 void RecordBrowserMainMessageLoopStart(const base::Time& time,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta) { 428 void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta) {
411 static bool is_first_call = true; 429 static bool is_first_call = true;
412 if (!is_first_call) 430 if (!is_first_call)
413 return; 431 return;
414 is_first_call = false; 432 is_first_call = false;
415 433
416 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(UMA_HISTOGRAM_LONG_TIMES_100, 434 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(UMA_HISTOGRAM_LONG_TIMES_100,
417 "Startup.BrowserOpenTabs", delta); 435 "Startup.BrowserOpenTabs", delta);
418 } 436 }
419 437
438 void RecordRendererMainEntryTime(const base::Time& time) {
439 // Record the renderer main entry time, but don't log the UMA metric
440 // immediately because the startup temperature is not known yet.
441 if (!g_renderer_main_entry_point_time.Get().is_null())
gab 2015/11/06 18:05:17 Shouldn't this be a positive check for is_null()?
fdoray 2015/11/09 15:53:56 Done.
442 g_renderer_main_entry_point_time.Get() = time;
443 }
444
420 void RecordFirstWebContentsMainFrameLoad(const base::Time& time) { 445 void RecordFirstWebContentsMainFrameLoad(const base::Time& time) {
421 static bool is_first_call = true; 446 static bool is_first_call = true;
422 if (!is_first_call || time.is_null()) 447 if (!is_first_call || time.is_null())
423 return; 448 return;
424 is_first_call = false; 449 is_first_call = false;
425 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null()) 450 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null())
426 return; 451 return;
427 452
428 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( 453 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE(
429 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.MainFrameLoad2", 454 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.MainFrameLoad2",
(...skipping 11 matching lines...) Expand all
441 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE( 466 UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(
442 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.MainFrameLoad", 467 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.MainFrameLoad",
443 time - g_process_creation_time.Get()); 468 time - g_process_creation_time.Get());
444 } 469 }
445 470
446 void RecordFirstWebContentsNonEmptyPaint(const base::Time& time) { 471 void RecordFirstWebContentsNonEmptyPaint(const base::Time& time) {
447 static bool is_first_call = true; 472 static bool is_first_call = true;
448 if (!is_first_call || time.is_null()) 473 if (!is_first_call || time.is_null())
449 return; 474 return;
450 is_first_call = false; 475 is_first_call = false;
476
477 // At this point, we know the first renderer main entry time and the startup
478 // temperature, so log Startup.BrowserDLLMainToRendererDLLMain.
gab 2015/11/06 18:05:17 Log Startup.BrowserDLLMainToRendererDLLMain now th
fdoray 2015/11/09 15:53:56 Done.
479 RecordRendererMainEntryHistogram();
480
451 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null()) 481 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null())
452 return; 482 return;
453 483
454 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( 484 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE(
455 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint2", 485 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint2",
456 g_process_creation_time.Get(), time); 486 g_process_creation_time.Get(), time);
457 } 487 }
458 488
459 void RecordDeprecatedFirstWebContentsNonEmptyPaint(const base::Time& time) { 489 void RecordDeprecatedFirstWebContentsNonEmptyPaint(const base::Time& time) {
460 static bool is_first_call = true; 490 static bool is_first_call = true;
(...skipping 30 matching lines...) Expand all
491 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null()) 521 if (WasNonBrowserUIDisplayed() || g_process_creation_time.Get().is_null())
492 return; 522 return;
493 523
494 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE( 524 UMA_HISTOGRAM_AND_TRACE_WITH_STARTUP_TEMPERATURE(
495 UMA_HISTOGRAM_LONG_TIMES_100, 525 UMA_HISTOGRAM_LONG_TIMES_100,
496 "Startup.FirstWebContents.MainNavigationFinished", 526 "Startup.FirstWebContents.MainNavigationFinished",
497 g_process_creation_time.Get(), time); 527 g_process_creation_time.Get(), time);
498 } 528 }
499 529
500 base::Time MainEntryPointTime() { 530 base::Time MainEntryPointTime() {
501 return g_main_entry_point_time.Get(); 531 return g_browser_main_entry_point_time.Get();
502 } 532 }
503 533
504 StartupTemperature GetStartupTemperature() { 534 StartupTemperature GetStartupTemperature() {
505 return g_startup_temperature; 535 return g_startup_temperature;
506 } 536 }
507 537
508 } // namespace startup_metric_utils 538 } // namespace startup_metric_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698