| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include <winternl.h> | 32 #include <winternl.h> |
| 33 #include "base/win/win_util.h" | 33 #include "base/win/win_util.h" |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 namespace startup_metric_utils { | 36 namespace startup_metric_utils { |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 // Mark as volatile to defensively make sure usage is thread-safe. | 40 // Mark as volatile to defensively make sure usage is thread-safe. |
| 41 // Note that at the time of this writing, access is only on the UI thread. | 41 // Note that at the time of this writing, access is only on the UI thread. |
| 42 volatile bool g_non_browser_ui_displayed = false; | 42 volatile bool g_main_window_startup_interrupted = false; |
| 43 | 43 |
| 44 base::LazyInstance<base::TimeTicks>::Leaky g_process_creation_ticks = | 44 base::LazyInstance<base::TimeTicks>::Leaky g_process_creation_ticks = |
| 45 LAZY_INSTANCE_INITIALIZER; | 45 LAZY_INSTANCE_INITIALIZER; |
| 46 | 46 |
| 47 base::LazyInstance<base::TimeTicks>::Leaky g_browser_main_entry_point_ticks = | 47 base::LazyInstance<base::TimeTicks>::Leaky g_browser_main_entry_point_ticks = |
| 48 LAZY_INSTANCE_INITIALIZER; | 48 LAZY_INSTANCE_INITIALIZER; |
| 49 | 49 |
| 50 base::LazyInstance<base::TimeTicks>::Leaky g_renderer_main_entry_point_ticks = | 50 base::LazyInstance<base::TimeTicks>::Leaky g_renderer_main_entry_point_ticks = |
| 51 LAZY_INSTANCE_INITIALIZER; | 51 LAZY_INSTANCE_INITIALIZER; |
| 52 | 52 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 } | 381 } |
| 382 #endif // defined(OS_WIN) | 382 #endif // defined(OS_WIN) |
| 383 } | 383 } |
| 384 | 384 |
| 385 // Converts a base::Time value to a base::TimeTicks value. The conversion isn't | 385 // Converts a base::Time value to a base::TimeTicks value. The conversion isn't |
| 386 // exact, but by capturing Time::Now() as early as possible, the likelihood of a | 386 // exact, but by capturing Time::Now() as early as possible, the likelihood of a |
| 387 // clock change between it and process start is as low as possible. There is | 387 // clock change between it and process start is as low as possible. There is |
| 388 // also the time taken to synchronously resolve base::Time::Now() and | 388 // also the time taken to synchronously resolve base::Time::Now() and |
| 389 // base::TimeTicks::Now() at play, but in practice it is pretty much instant | 389 // base::TimeTicks::Now() at play, but in practice it is pretty much instant |
| 390 // compared to multi-seconds startup timings. | 390 // compared to multi-seconds startup timings. |
| 391 base::TimeTicks StartupTimeToTimeTicks(const base::Time& time) { | 391 base::TimeTicks StartupTimeToTimeTicks(base::Time time) { |
| 392 // First get a base which represents the same point in time in both units. | 392 // First get a base which represents the same point in time in both units. |
| 393 // Bump the priority of this thread while doing this as the wall clock time it | 393 // Bump the priority of this thread while doing this as the wall clock time it |
| 394 // takes to resolve these two calls affects the precision of this method and | 394 // takes to resolve these two calls affects the precision of this method and |
| 395 // bumping the priority reduces the likelihood of a context switch interfering | 395 // bumping the priority reduces the likelihood of a context switch interfering |
| 396 // with this computation. | 396 // with this computation. |
| 397 | 397 |
| 398 // Enabling this logic on OS X causes a significant performance regression. | 398 // Enabling this logic on OS X causes a significant performance regression. |
| 399 // https://crbug.com/601270 | 399 // https://crbug.com/601270 |
| 400 #if !defined(OS_MACOSX) | 400 #if !defined(OS_MACOSX) |
| 401 static bool statics_initialized = false; | 401 static bool statics_initialized = false; |
| 402 | 402 |
| 403 base::ThreadPriority previous_priority = base::ThreadPriority::NORMAL; | 403 base::ThreadPriority previous_priority = base::ThreadPriority::NORMAL; |
| 404 if (!statics_initialized) { | 404 if (!statics_initialized) { |
| 405 previous_priority = base::PlatformThread::GetCurrentThreadPriority(); | 405 previous_priority = base::PlatformThread::GetCurrentThreadPriority(); |
| 406 base::PlatformThread::SetCurrentThreadPriority( | 406 base::PlatformThread::SetCurrentThreadPriority( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 // TODO(gabadie): Once startup_with_url.* benchmarks are replaced by | 448 // TODO(gabadie): Once startup_with_url.* benchmarks are replaced by |
| 449 // startup_with_url2.*, remove this dirty hack (crbug.com/539287). | 449 // startup_with_url2.*, remove this dirty hack (crbug.com/539287). |
| 450 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteHighWord", | 450 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteHighWord", |
| 451 browser_main_entry_time_raw_ms_high_word); | 451 browser_main_entry_time_raw_ms_high_word); |
| 452 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteLowWord", | 452 LOCAL_HISTOGRAM_TIMES("Startup.BrowserMainEntryTimeAbsoluteLowWord", |
| 453 browser_main_entry_time_raw_ms_low_word); | 453 browser_main_entry_time_raw_ms_low_word); |
| 454 } | 454 } |
| 455 | 455 |
| 456 // Record renderer main entry time histogram. | 456 // Record renderer main entry time histogram. |
| 457 void RecordRendererMainEntryHistogram() { | 457 void RecordRendererMainEntryHistogram() { |
| 458 const base::TimeTicks& browser_main_entry_point_ticks = | 458 const base::TimeTicks browser_main_entry_point_ticks = |
| 459 g_browser_main_entry_point_ticks.Get(); | 459 g_browser_main_entry_point_ticks.Get(); |
| 460 const base::TimeTicks& renderer_main_entry_point_ticks = | 460 const base::TimeTicks renderer_main_entry_point_ticks = |
| 461 g_renderer_main_entry_point_ticks.Get(); | 461 g_renderer_main_entry_point_ticks.Get(); |
| 462 | 462 |
| 463 if (!browser_main_entry_point_ticks.is_null() && | 463 if (!browser_main_entry_point_ticks.is_null() && |
| 464 !renderer_main_entry_point_ticks.is_null()) { | 464 !renderer_main_entry_point_ticks.is_null()) { |
| 465 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( | 465 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( |
| 466 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMainToRendererMain", | 466 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMainToRendererMain", |
| 467 browser_main_entry_point_ticks, renderer_main_entry_point_ticks); | 467 browser_main_entry_point_ticks, renderer_main_entry_point_ticks); |
| 468 } | 468 } |
| 469 } | 469 } |
| 470 | 470 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 } else { | 541 } else { |
| 542 g_startups_with_current_version = 1; | 542 g_startups_with_current_version = 1; |
| 543 pref_service->SetString(prefs::kLastStartupVersion, current_version); | 543 pref_service->SetString(prefs::kLastStartupVersion, current_version); |
| 544 pref_service->SetInteger(prefs::kSameVersionStartupCount, 1); | 544 pref_service->SetInteger(prefs::kSameVersionStartupCount, 1); |
| 545 } | 545 } |
| 546 | 546 |
| 547 UMA_HISTOGRAM_COUNTS_100("Startup.SameVersionStartupCount", | 547 UMA_HISTOGRAM_COUNTS_100("Startup.SameVersionStartupCount", |
| 548 g_startups_with_current_version); | 548 g_startups_with_current_version); |
| 549 } | 549 } |
| 550 | 550 |
| 551 bool ShouldLogStartupHistogram() { |
| 552 return !WasMainWindowStartupInterrupted() && |
| 553 !g_process_creation_ticks.Get().is_null(); |
| 554 } |
| 555 |
| 551 } // namespace | 556 } // namespace |
| 552 | 557 |
| 553 void RegisterPrefs(PrefRegistrySimple* registry) { | 558 void RegisterPrefs(PrefRegistrySimple* registry) { |
| 554 DCHECK(registry); | 559 DCHECK(registry); |
| 555 registry->RegisterInt64Pref(prefs::kLastStartupTimestamp, 0); | 560 registry->RegisterInt64Pref(prefs::kLastStartupTimestamp, 0); |
| 556 registry->RegisterStringPref(prefs::kLastStartupVersion, std::string()); | 561 registry->RegisterStringPref(prefs::kLastStartupVersion, std::string()); |
| 557 registry->RegisterIntegerPref(prefs::kSameVersionStartupCount, 0); | 562 registry->RegisterIntegerPref(prefs::kSameVersionStartupCount, 0); |
| 558 } | 563 } |
| 559 | 564 |
| 560 bool WasNonBrowserUIDisplayed() { | 565 bool WasMainWindowStartupInterrupted() { |
| 561 return g_non_browser_ui_displayed; | 566 return g_main_window_startup_interrupted; |
| 562 } | 567 } |
| 563 | 568 |
| 564 void SetNonBrowserUIDisplayed() { | 569 void SetNonBrowserUIDisplayed() { |
| 565 g_non_browser_ui_displayed = true; | 570 g_main_window_startup_interrupted = true; |
| 566 } | 571 } |
| 567 | 572 |
| 568 void RecordStartupProcessCreationTime(const base::Time& time) { | 573 void SetBackgroundModeEnabled() { |
| 574 g_main_window_startup_interrupted = true; |
| 575 } |
| 576 |
| 577 void RecordStartupProcessCreationTime(base::Time time) { |
| 569 DCHECK(g_process_creation_ticks.Get().is_null()); | 578 DCHECK(g_process_creation_ticks.Get().is_null()); |
| 570 g_process_creation_ticks.Get() = StartupTimeToTimeTicks(time); | 579 g_process_creation_ticks.Get() = StartupTimeToTimeTicks(time); |
| 571 DCHECK(!g_process_creation_ticks.Get().is_null()); | 580 DCHECK(!g_process_creation_ticks.Get().is_null()); |
| 572 } | 581 } |
| 573 | 582 |
| 574 void RecordMainEntryPointTime(const base::Time& time) { | 583 void RecordMainEntryPointTime(base::Time time) { |
| 575 DCHECK(g_browser_main_entry_point_ticks.Get().is_null()); | 584 DCHECK(g_browser_main_entry_point_ticks.Get().is_null()); |
| 576 g_browser_main_entry_point_ticks.Get() = StartupTimeToTimeTicks(time); | 585 g_browser_main_entry_point_ticks.Get() = StartupTimeToTimeTicks(time); |
| 577 DCHECK(!g_browser_main_entry_point_ticks.Get().is_null()); | 586 DCHECK(!g_browser_main_entry_point_ticks.Get().is_null()); |
| 578 | 587 |
| 579 // TODO(jeremy): Remove this with RecordMainEntryTimeHistogram() when | 588 // TODO(jeremy): Remove this with RecordMainEntryTimeHistogram() when |
| 580 // resolving crbug.com/317481. | 589 // resolving crbug.com/317481. |
| 581 DCHECK(g_browser_main_entry_point_time.Get().is_null()); | 590 DCHECK(g_browser_main_entry_point_time.Get().is_null()); |
| 582 g_browser_main_entry_point_time.Get() = time; | 591 g_browser_main_entry_point_time.Get() = time; |
| 583 DCHECK(!g_browser_main_entry_point_time.Get().is_null()); | 592 DCHECK(!g_browser_main_entry_point_time.Get().is_null()); |
| 584 } | 593 } |
| 585 | 594 |
| 586 void RecordExeMainEntryPointTicks(const base::TimeTicks& ticks) { | 595 void RecordExeMainEntryPointTicks(base::TimeTicks ticks) { |
| 587 DCHECK(g_browser_exe_main_entry_point_ticks.Get().is_null()); | 596 DCHECK(g_browser_exe_main_entry_point_ticks.Get().is_null()); |
| 588 g_browser_exe_main_entry_point_ticks.Get() = ticks; | 597 g_browser_exe_main_entry_point_ticks.Get() = ticks; |
| 589 DCHECK(!g_browser_exe_main_entry_point_ticks.Get().is_null()); | 598 DCHECK(!g_browser_exe_main_entry_point_ticks.Get().is_null()); |
| 590 } | 599 } |
| 591 | 600 |
| 592 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, | 601 void RecordBrowserMainMessageLoopStart(base::TimeTicks ticks, |
| 593 bool is_first_run, | 602 bool is_first_run, |
| 594 PrefService* pref_service) { | 603 PrefService* pref_service) { |
| 595 DCHECK(pref_service); | 604 DCHECK(pref_service); |
| 596 | 605 |
| 597 // Keep RecordSameVersionStartupCount() and RecordHardFaultHistogram() | 606 // Keep RecordSameVersionStartupCount() and RecordHardFaultHistogram() |
| 598 // near the top of this method (as much as possible) as many other | 607 // near the top of this method (as much as possible) as many other |
| 599 // histograms depend on it setting |g_startup_temperature| and | 608 // histograms depend on it setting |g_startup_temperature| and |
| 600 // |g_startups_with_current_version|. | 609 // |g_startups_with_current_version|. |
| 601 RecordSameVersionStartupCount(pref_service); | 610 RecordSameVersionStartupCount(pref_service); |
| 602 RecordHardFaultHistogram(); | 611 RecordHardFaultHistogram(); |
| 603 | 612 |
| 604 // Record timing of the browser message-loop start time. | 613 // Record timing of the browser message-loop start time. |
| 605 base::StackSamplingProfiler::SetProcessMilestone( | 614 base::StackSamplingProfiler::SetProcessMilestone( |
| 606 metrics::CallStackProfileMetricsProvider::MAIN_LOOP_START); | 615 metrics::CallStackProfileMetricsProvider::MAIN_LOOP_START); |
| 607 const base::TimeTicks& process_creation_ticks = | 616 const base::TimeTicks process_creation_ticks = g_process_creation_ticks.Get(); |
| 608 g_process_creation_ticks.Get(); | |
| 609 if (!is_first_run && !process_creation_ticks.is_null()) { | 617 if (!is_first_run && !process_creation_ticks.is_null()) { |
| 610 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( | 618 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( |
| 611 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime", | 619 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime", |
| 612 process_creation_ticks, ticks); | 620 process_creation_ticks, ticks); |
| 613 } | 621 } |
| 614 | 622 |
| 615 // Record timing between the shared library's main() entry and the browser | 623 // Record timing between the shared library's main() entry and the browser |
| 616 // main message loop start. | 624 // main message loop start. |
| 617 if (is_first_run) { | 625 if (is_first_run) { |
| 618 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE( | 626 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 exe_main_ticks, main_entry_ticks); | 658 exe_main_ticks, main_entry_ticks); |
| 651 | 659 |
| 652 // Process create to chrome.dll:main(). Reported as a histogram only as | 660 // Process create to chrome.dll:main(). Reported as a histogram only as |
| 653 // the other two events above are sufficient for tracing purposes. | 661 // the other two events above are sufficient for tracing purposes. |
| 654 UMA_HISTOGRAM_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( | 662 UMA_HISTOGRAM_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( |
| 655 UMA_HISTOGRAM_LONG_TIMES, "Startup.LoadTime.ProcessCreateToDllMain2", | 663 UMA_HISTOGRAM_LONG_TIMES, "Startup.LoadTime.ProcessCreateToDllMain2", |
| 656 main_entry_ticks - process_creation_ticks); | 664 main_entry_ticks - process_creation_ticks); |
| 657 } | 665 } |
| 658 } | 666 } |
| 659 | 667 |
| 660 void RecordBrowserWindowDisplay(const base::TimeTicks& ticks) { | 668 void RecordBrowserWindowDisplay(base::TimeTicks ticks) { |
| 661 static bool is_first_call = true; | 669 static bool is_first_call = true; |
| 662 if (!is_first_call || ticks.is_null()) | 670 if (!is_first_call || ticks.is_null()) |
| 663 return; | 671 return; |
| 664 is_first_call = false; | 672 is_first_call = false; |
| 665 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) | 673 if (!ShouldLogStartupHistogram()) |
| 666 return; | 674 return; |
| 667 | 675 |
| 668 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( | 676 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( |
| 669 UMA_HISTOGRAM_LONG_TIMES, "Startup.BrowserWindowDisplay", | 677 UMA_HISTOGRAM_LONG_TIMES, "Startup.BrowserWindowDisplay", |
| 670 g_process_creation_ticks.Get(), ticks); | 678 g_process_creation_ticks.Get(), ticks); |
| 671 } | 679 } |
| 672 | 680 |
| 673 void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta) { | 681 void RecordBrowserOpenTabsDelta(base::TimeDelta delta) { |
| 674 static bool is_first_call = true; | 682 static bool is_first_call = true; |
| 675 if (!is_first_call) | 683 if (!is_first_call) |
| 676 return; | 684 return; |
| 677 is_first_call = false; | 685 is_first_call = false; |
| 678 | 686 |
| 679 UMA_HISTOGRAM_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( | 687 UMA_HISTOGRAM_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( |
| 680 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserOpenTabs", delta); | 688 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserOpenTabs", delta); |
| 681 } | 689 } |
| 682 | 690 |
| 683 void RecordRendererMainEntryTime(const base::TimeTicks& ticks) { | 691 void RecordRendererMainEntryTime(base::TimeTicks ticks) { |
| 684 // Record the renderer main entry time, but don't log the UMA metric | 692 // Record the renderer main entry time, but don't log the UMA metric |
| 685 // immediately because the startup temperature is not known yet. | 693 // immediately because the startup temperature is not known yet. |
| 686 if (g_renderer_main_entry_point_ticks.Get().is_null()) | 694 if (g_renderer_main_entry_point_ticks.Get().is_null()) |
| 687 g_renderer_main_entry_point_ticks.Get() = ticks; | 695 g_renderer_main_entry_point_ticks.Get() = ticks; |
| 688 } | 696 } |
| 689 | 697 |
| 690 void RecordFirstWebContentsMainFrameLoad(const base::TimeTicks& ticks) { | 698 void RecordFirstWebContentsMainFrameLoad(base::TimeTicks ticks) { |
| 691 static bool is_first_call = true; | 699 static bool is_first_call = true; |
| 692 if (!is_first_call || ticks.is_null()) | 700 if (!is_first_call || ticks.is_null()) |
| 693 return; | 701 return; |
| 694 is_first_call = false; | 702 is_first_call = false; |
| 695 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) | 703 if (!ShouldLogStartupHistogram()) |
| 696 return; | 704 return; |
| 697 | 705 |
| 698 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( | 706 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( |
| 699 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.MainFrameLoad2", | 707 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.MainFrameLoad2", |
| 700 g_process_creation_ticks.Get(), ticks); | 708 g_process_creation_ticks.Get(), ticks); |
| 701 } | 709 } |
| 702 | 710 |
| 703 void RecordFirstWebContentsNonEmptyPaint(const base::TimeTicks& ticks) { | 711 void RecordFirstWebContentsNonEmptyPaint(base::TimeTicks ticks) { |
| 704 static bool is_first_call = true; | 712 static bool is_first_call = true; |
| 705 if (!is_first_call || ticks.is_null()) | 713 if (!is_first_call || ticks.is_null()) |
| 706 return; | 714 return; |
| 707 is_first_call = false; | 715 is_first_call = false; |
| 708 | 716 |
| 709 // Log Startup.BrowserMainToRendererMain now that the first renderer main | 717 // Log Startup.BrowserMainToRendererMain now that the first renderer main |
| 710 // entry time and the startup temperature are known. | 718 // entry time and the startup temperature are known. |
| 711 RecordRendererMainEntryHistogram(); | 719 RecordRendererMainEntryHistogram(); |
| 712 | 720 |
| 713 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) | 721 if (!ShouldLogStartupHistogram()) |
| 714 return; | 722 return; |
| 715 | 723 |
| 716 base::StackSamplingProfiler::SetProcessMilestone( | 724 base::StackSamplingProfiler::SetProcessMilestone( |
| 717 metrics::CallStackProfileMetricsProvider::FIRST_NONEMPTY_PAINT); | 725 metrics::CallStackProfileMetricsProvider::FIRST_NONEMPTY_PAINT); |
| 718 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( | 726 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( |
| 719 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint2", | 727 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint2", |
| 720 g_process_creation_ticks.Get(), ticks); | 728 g_process_creation_ticks.Get(), ticks); |
| 721 } | 729 } |
| 722 | 730 |
| 723 void RecordFirstWebContentsMainNavigationStart(const base::TimeTicks& ticks, | 731 void RecordFirstWebContentsMainNavigationStart(base::TimeTicks ticks, |
| 724 WebContentsWorkload workload) { | 732 WebContentsWorkload workload) { |
| 725 static bool is_first_call = true; | 733 static bool is_first_call = true; |
| 726 if (!is_first_call || ticks.is_null()) | 734 if (!is_first_call || ticks.is_null()) |
| 727 return; | 735 return; |
| 728 is_first_call = false; | 736 is_first_call = false; |
| 729 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) | 737 if (!ShouldLogStartupHistogram()) |
| 730 return; | 738 return; |
| 731 | 739 |
| 732 base::StackSamplingProfiler::SetProcessMilestone( | 740 base::StackSamplingProfiler::SetProcessMilestone( |
| 733 metrics::CallStackProfileMetricsProvider::MAIN_NAVIGATION_START); | 741 metrics::CallStackProfileMetricsProvider::MAIN_NAVIGATION_START); |
| 734 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( | 742 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( |
| 735 UMA_HISTOGRAM_LONG_TIMES_100, | 743 UMA_HISTOGRAM_LONG_TIMES_100, |
| 736 "Startup.FirstWebContents.MainNavigationStart", | 744 "Startup.FirstWebContents.MainNavigationStart", |
| 737 g_process_creation_ticks.Get(), ticks); | 745 g_process_creation_ticks.Get(), ticks); |
| 738 | 746 |
| 739 // Log extra information about this startup's workload. Only added to this | 747 // Log extra information about this startup's workload. Only added to this |
| 740 // histogram as this extra suffix can help making it less noisy but isn't | 748 // histogram as this extra suffix can help making it less noisy but isn't |
| 741 // worth tripling the number of startup histograms either. | 749 // worth tripling the number of startup histograms either. |
| 742 if (workload == WebContentsWorkload::SINGLE_TAB) { | 750 if (workload == WebContentsWorkload::SINGLE_TAB) { |
| 743 UMA_HISTOGRAM_WITH_TEMPERATURE( | 751 UMA_HISTOGRAM_WITH_TEMPERATURE( |
| 744 UMA_HISTOGRAM_LONG_TIMES_100, | 752 UMA_HISTOGRAM_LONG_TIMES_100, |
| 745 "Startup.FirstWebContents.MainNavigationStart.SingleTab", | 753 "Startup.FirstWebContents.MainNavigationStart.SingleTab", |
| 746 ticks - g_process_creation_ticks.Get()); | 754 ticks - g_process_creation_ticks.Get()); |
| 747 } else { | 755 } else { |
| 748 UMA_HISTOGRAM_WITH_TEMPERATURE( | 756 UMA_HISTOGRAM_WITH_TEMPERATURE( |
| 749 UMA_HISTOGRAM_LONG_TIMES_100, | 757 UMA_HISTOGRAM_LONG_TIMES_100, |
| 750 "Startup.FirstWebContents.MainNavigationStart.MultiTabs", | 758 "Startup.FirstWebContents.MainNavigationStart.MultiTabs", |
| 751 ticks - g_process_creation_ticks.Get()); | 759 ticks - g_process_creation_ticks.Get()); |
| 752 } | 760 } |
| 753 } | 761 } |
| 754 | 762 |
| 755 void RecordFirstWebContentsMainNavigationFinished( | 763 void RecordFirstWebContentsMainNavigationFinished(base::TimeTicks ticks) { |
| 756 const base::TimeTicks& ticks) { | |
| 757 static bool is_first_call = true; | 764 static bool is_first_call = true; |
| 758 if (!is_first_call || ticks.is_null()) | 765 if (!is_first_call || ticks.is_null()) |
| 759 return; | 766 return; |
| 760 is_first_call = false; | 767 is_first_call = false; |
| 761 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) | 768 if (!ShouldLogStartupHistogram()) |
| 762 return; | 769 return; |
| 763 | 770 |
| 764 base::StackSamplingProfiler::SetProcessMilestone( | 771 base::StackSamplingProfiler::SetProcessMilestone( |
| 765 metrics::CallStackProfileMetricsProvider::MAIN_NAVIGATION_FINISHED); | 772 metrics::CallStackProfileMetricsProvider::MAIN_NAVIGATION_FINISHED); |
| 766 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( | 773 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( |
| 767 UMA_HISTOGRAM_LONG_TIMES_100, | 774 UMA_HISTOGRAM_LONG_TIMES_100, |
| 768 "Startup.FirstWebContents.MainNavigationFinished", | 775 "Startup.FirstWebContents.MainNavigationFinished", |
| 769 g_process_creation_ticks.Get(), ticks); | 776 g_process_creation_ticks.Get(), ticks); |
| 770 } | 777 } |
| 771 | 778 |
| 779 void RecordBrowserWindowFirstPaint(base::TimeTicks ticks) { |
| 780 static bool is_first_call = true; |
| 781 if (!is_first_call || ticks.is_null()) |
| 782 return; |
| 783 is_first_call = false; |
| 784 if (!ShouldLogStartupHistogram()) |
| 785 return; |
| 786 |
| 787 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE( |
| 788 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserWindow.FirstPaint", |
| 789 g_process_creation_ticks.Get(), ticks); |
| 790 } |
| 791 |
| 792 void RecordBrowserWindowFirstPaintCompositingEnded( |
| 793 const base::TimeTicks ticks) { |
| 794 static bool is_first_call = true; |
| 795 if (!is_first_call || ticks.is_null()) |
| 796 return; |
| 797 is_first_call = false; |
| 798 if (!ShouldLogStartupHistogram()) |
| 799 return; |
| 800 |
| 801 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE( |
| 802 UMA_HISTOGRAM_LONG_TIMES_100, |
| 803 "Startup.BrowserWindow.FirstPaint.CompositingEnded", |
| 804 g_process_creation_ticks.Get(), ticks); |
| 805 } |
| 806 |
| 772 base::TimeTicks MainEntryPointTicks() { | 807 base::TimeTicks MainEntryPointTicks() { |
| 773 return g_browser_main_entry_point_ticks.Get(); | 808 return g_browser_main_entry_point_ticks.Get(); |
| 774 } | 809 } |
| 775 | 810 |
| 776 } // namespace startup_metric_utils | 811 } // namespace startup_metric_utils |
| OLD | NEW |