| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 53 base::LazyInstance<base::TimeTicks>::Leaky | 53 base::LazyInstance<base::TimeTicks>::Leaky |
| 54 g_browser_exe_main_entry_point_ticks = LAZY_INSTANCE_INITIALIZER; | 54 g_browser_exe_main_entry_point_ticks = LAZY_INSTANCE_INITIALIZER; |
| 55 | 55 |
| 56 base::LazyInstance<base::TimeTicks>::Leaky g_message_loop_start_ticks = |
| 57 LAZY_INSTANCE_INITIALIZER; |
| 58 |
| 56 // Only used by RecordMainEntryTimeHistogram(), should go away with it (do not | 59 // Only used by RecordMainEntryTimeHistogram(), should go away with it (do not |
| 57 // add new uses of this), see crbug.com/317481 for discussion on why it was kept | 60 // add new uses of this), see crbug.com/317481 for discussion on why it was kept |
| 58 // as-is for now. | 61 // as-is for now. |
| 59 base::LazyInstance<base::Time>::Leaky g_browser_main_entry_point_time = | 62 base::LazyInstance<base::Time>::Leaky g_browser_main_entry_point_time = |
| 60 LAZY_INSTANCE_INITIALIZER; | 63 LAZY_INSTANCE_INITIALIZER; |
| 61 | 64 |
| 62 // An enumeration of startup temperatures. This must be kept in sync with the | 65 // An enumeration of startup temperatures. This must be kept in sync with the |
| 63 // UMA StartupType enumeration defined in histograms.xml. | 66 // UMA StartupType enumeration defined in histograms.xml. |
| 64 enum StartupTemperature { | 67 enum StartupTemperature { |
| 65 // The startup was a cold start: nearly all of the binaries and resources were | 68 // The startup was a cold start: nearly all of the binaries and resources were |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 g_browser_main_entry_point_time.Get() = time; | 594 g_browser_main_entry_point_time.Get() = time; |
| 592 DCHECK(!g_browser_main_entry_point_time.Get().is_null()); | 595 DCHECK(!g_browser_main_entry_point_time.Get().is_null()); |
| 593 } | 596 } |
| 594 | 597 |
| 595 void RecordExeMainEntryPointTicks(base::TimeTicks ticks) { | 598 void RecordExeMainEntryPointTicks(base::TimeTicks ticks) { |
| 596 DCHECK(g_browser_exe_main_entry_point_ticks.Get().is_null()); | 599 DCHECK(g_browser_exe_main_entry_point_ticks.Get().is_null()); |
| 597 g_browser_exe_main_entry_point_ticks.Get() = ticks; | 600 g_browser_exe_main_entry_point_ticks.Get() = ticks; |
| 598 DCHECK(!g_browser_exe_main_entry_point_ticks.Get().is_null()); | 601 DCHECK(!g_browser_exe_main_entry_point_ticks.Get().is_null()); |
| 599 } | 602 } |
| 600 | 603 |
| 604 void RecordMessageLoopStartTicks(base::TimeTicks ticks) { |
| 605 DCHECK(g_message_loop_start_ticks.Get().is_null()); |
| 606 g_message_loop_start_ticks.Get() = ticks; |
| 607 DCHECK(!g_message_loop_start_ticks.Get().is_null()); |
| 608 } |
| 609 |
| 601 void RecordBrowserMainMessageLoopStart(base::TimeTicks ticks, | 610 void RecordBrowserMainMessageLoopStart(base::TimeTicks ticks, |
| 602 bool is_first_run, | 611 bool is_first_run, |
| 603 PrefService* pref_service) { | 612 PrefService* pref_service) { |
| 604 DCHECK(pref_service); | 613 DCHECK(pref_service); |
| 614 RecordMessageLoopStartTicks(ticks); |
| 605 | 615 |
| 606 // Keep RecordSameVersionStartupCount() and RecordHardFaultHistogram() | 616 // Keep RecordSameVersionStartupCount() and RecordHardFaultHistogram() |
| 607 // near the top of this method (as much as possible) as many other | 617 // near the top of this method (as much as possible) as many other |
| 608 // histograms depend on it setting |g_startup_temperature| and | 618 // histograms depend on it setting |g_startup_temperature| and |
| 609 // |g_startups_with_current_version|. | 619 // |g_startups_with_current_version|. |
| 610 RecordSameVersionStartupCount(pref_service); | 620 RecordSameVersionStartupCount(pref_service); |
| 611 RecordHardFaultHistogram(); | 621 RecordHardFaultHistogram(); |
| 612 | 622 |
| 613 // Record timing of the browser message-loop start time. | 623 // Record timing of the browser message-loop start time. |
| 614 base::StackSamplingProfiler::SetProcessMilestone( | 624 base::StackSamplingProfiler::SetProcessMilestone( |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 RecordRendererMainEntryHistogram(); | 729 RecordRendererMainEntryHistogram(); |
| 720 | 730 |
| 721 if (!ShouldLogStartupHistogram()) | 731 if (!ShouldLogStartupHistogram()) |
| 722 return; | 732 return; |
| 723 | 733 |
| 724 base::StackSamplingProfiler::SetProcessMilestone( | 734 base::StackSamplingProfiler::SetProcessMilestone( |
| 725 metrics::CallStackProfileMetricsProvider::FIRST_NONEMPTY_PAINT); | 735 metrics::CallStackProfileMetricsProvider::FIRST_NONEMPTY_PAINT); |
| 726 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( | 736 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( |
| 727 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint2", | 737 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint2", |
| 728 g_process_creation_ticks.Get(), ticks); | 738 g_process_creation_ticks.Get(), ticks); |
| 739 UMA_HISTOGRAM_WITH_TEMPERATURE( |
| 740 UMA_HISTOGRAM_LONG_TIMES_100, |
| 741 "Startup.BrowserMessageLoopStart.To.NonEmptyPaint2", |
| 742 ticks - g_message_loop_start_ticks.Get()); |
| 729 } | 743 } |
| 730 | 744 |
| 731 void RecordFirstWebContentsMainNavigationStart(base::TimeTicks ticks, | 745 void RecordFirstWebContentsMainNavigationStart(base::TimeTicks ticks, |
| 732 WebContentsWorkload workload) { | 746 WebContentsWorkload workload) { |
| 733 static bool is_first_call = true; | 747 static bool is_first_call = true; |
| 734 if (!is_first_call || ticks.is_null()) | 748 if (!is_first_call || ticks.is_null()) |
| 735 return; | 749 return; |
| 736 is_first_call = false; | 750 is_first_call = false; |
| 737 if (!ShouldLogStartupHistogram()) | 751 if (!ShouldLogStartupHistogram()) |
| 738 return; | 752 return; |
| 739 | 753 |
| 740 base::StackSamplingProfiler::SetProcessMilestone( | 754 base::StackSamplingProfiler::SetProcessMilestone( |
| 741 metrics::CallStackProfileMetricsProvider::MAIN_NAVIGATION_START); | 755 metrics::CallStackProfileMetricsProvider::MAIN_NAVIGATION_START); |
| 742 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( | 756 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( |
| 743 UMA_HISTOGRAM_LONG_TIMES_100, | 757 UMA_HISTOGRAM_LONG_TIMES_100, |
| 744 "Startup.FirstWebContents.MainNavigationStart", | 758 "Startup.FirstWebContents.MainNavigationStart", |
| 745 g_process_creation_ticks.Get(), ticks); | 759 g_process_creation_ticks.Get(), ticks); |
| 760 UMA_HISTOGRAM_WITH_TEMPERATURE( |
| 761 UMA_HISTOGRAM_LONG_TIMES_100, |
| 762 "Startup.BrowserMessageLoopStart.To.MainNavigationStart", |
| 763 ticks - g_message_loop_start_ticks.Get()); |
| 746 | 764 |
| 747 // Log extra information about this startup's workload. Only added to this | 765 // Log extra information about this startup's workload. Only added to this |
| 748 // histogram as this extra suffix can help making it less noisy but isn't | 766 // histogram as this extra suffix can help making it less noisy but isn't |
| 749 // worth tripling the number of startup histograms either. | 767 // worth tripling the number of startup histograms either. |
| 750 if (workload == WebContentsWorkload::SINGLE_TAB) { | 768 if (workload == WebContentsWorkload::SINGLE_TAB) { |
| 751 UMA_HISTOGRAM_WITH_TEMPERATURE( | 769 UMA_HISTOGRAM_WITH_TEMPERATURE( |
| 752 UMA_HISTOGRAM_LONG_TIMES_100, | 770 UMA_HISTOGRAM_LONG_TIMES_100, |
| 753 "Startup.FirstWebContents.MainNavigationStart.SingleTab", | 771 "Startup.FirstWebContents.MainNavigationStart.SingleTab", |
| 754 ticks - g_process_creation_ticks.Get()); | 772 ticks - g_process_creation_ticks.Get()); |
| 755 } else { | 773 } else { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 UMA_HISTOGRAM_LONG_TIMES_100, | 820 UMA_HISTOGRAM_LONG_TIMES_100, |
| 803 "Startup.BrowserWindow.FirstPaint.CompositingEnded", | 821 "Startup.BrowserWindow.FirstPaint.CompositingEnded", |
| 804 g_process_creation_ticks.Get(), ticks); | 822 g_process_creation_ticks.Get(), ticks); |
| 805 } | 823 } |
| 806 | 824 |
| 807 base::TimeTicks MainEntryPointTicks() { | 825 base::TimeTicks MainEntryPointTicks() { |
| 808 return g_browser_main_entry_point_ticks.Get(); | 826 return g_browser_main_entry_point_ticks.Get(); |
| 809 } | 827 } |
| 810 | 828 |
| 811 } // namespace startup_metric_utils | 829 } // namespace startup_metric_utils |
| OLD | NEW |