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

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

Issue 2913423003: Refactor recording of the Startup.FirstWebContents.RenderProcessHostInit.ToNonEmptyPaint metric
Patch Set: Created 3 years, 6 months 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 29 matching lines...) Expand all
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_main_window_startup_interrupted = 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
51 g_first_render_process_host_init_ticks = LAZY_INSTANCE_INITIALIZER;
52
50 base::LazyInstance<base::TimeTicks>::Leaky g_renderer_main_entry_point_ticks = 53 base::LazyInstance<base::TimeTicks>::Leaky g_renderer_main_entry_point_ticks =
51 LAZY_INSTANCE_INITIALIZER; 54 LAZY_INSTANCE_INITIALIZER;
52 55
53 base::LazyInstance<base::TimeTicks>::Leaky 56 base::LazyInstance<base::TimeTicks>::Leaky
54 g_browser_exe_main_entry_point_ticks = LAZY_INSTANCE_INITIALIZER; 57 g_browser_exe_main_entry_point_ticks = LAZY_INSTANCE_INITIALIZER;
55 58
56 base::LazyInstance<base::TimeTicks>::Leaky g_message_loop_start_ticks = 59 base::LazyInstance<base::TimeTicks>::Leaky g_message_loop_start_ticks =
57 LAZY_INSTANCE_INITIALIZER; 60 LAZY_INSTANCE_INITIALIZER;
58 61
59 // Only used by RecordMainEntryTimeHistogram(), should go away with it (do not 62 // Only used by RecordMainEntryTimeHistogram(), should go away with it (do not
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 void RecordBrowserOpenTabsDelta(base::TimeDelta delta) { 694 void RecordBrowserOpenTabsDelta(base::TimeDelta delta) {
692 static bool is_first_call = true; 695 static bool is_first_call = true;
693 if (!is_first_call) 696 if (!is_first_call)
694 return; 697 return;
695 is_first_call = false; 698 is_first_call = false;
696 699
697 UMA_HISTOGRAM_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( 700 UMA_HISTOGRAM_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT(
698 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserOpenTabs", delta); 701 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserOpenTabs", delta);
699 } 702 }
700 703
704 void RecordFirstRenderProcessHostInit(base::TimeTicks ticks) {
705 if (g_first_render_process_host_init_ticks.Get().is_null())
706 g_first_render_process_host_init_ticks.Get() = ticks;
707 }
708
701 void RecordRendererMainEntryTime(base::TimeTicks ticks) { 709 void RecordRendererMainEntryTime(base::TimeTicks ticks) {
702 // Record the renderer main entry time, but don't log the UMA metric 710 // Record the renderer main entry time, but don't log the UMA metric
703 // immediately because the startup temperature is not known yet. 711 // immediately because the startup temperature is not known yet.
704 if (g_renderer_main_entry_point_ticks.Get().is_null()) 712 if (g_renderer_main_entry_point_ticks.Get().is_null())
705 g_renderer_main_entry_point_ticks.Get() = ticks; 713 g_renderer_main_entry_point_ticks.Get() = ticks;
706 } 714 }
707 715
708 void RecordFirstWebContentsMainFrameLoad(base::TimeTicks ticks) { 716 void RecordFirstWebContentsMainFrameLoad(base::TimeTicks ticks) {
709 static bool is_first_call = true; 717 static bool is_first_call = true;
710 if (!is_first_call || ticks.is_null()) 718 if (!is_first_call || ticks.is_null())
711 return; 719 return;
712 is_first_call = false; 720 is_first_call = false;
713 if (!ShouldLogStartupHistogram()) 721 if (!ShouldLogStartupHistogram())
714 return; 722 return;
715 723
716 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( 724 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT(
717 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.MainFrameLoad2", 725 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.MainFrameLoad2",
718 g_process_creation_ticks.Get(), ticks); 726 g_process_creation_ticks.Get(), ticks);
719 } 727 }
720 728
721 void RecordFirstWebContentsNonEmptyPaint( 729 void RecordFirstWebContentsNonEmptyPaint(base::TimeTicks ticks) {
722 base::TimeTicks now,
723 base::TimeTicks render_process_host_init_time) {
724 static bool is_first_call = true; 730 static bool is_first_call = true;
725 if (!is_first_call || now.is_null()) 731 if (!is_first_call || ticks.is_null())
726 return; 732 return;
727 is_first_call = false; 733 is_first_call = false;
728 734
729 // Log Startup.BrowserMainToRendererMain now that the first renderer main 735 // Log Startup.BrowserMainToRendererMain now that the first renderer main
730 // entry time and the startup temperature are known. 736 // entry time and the startup temperature are known.
731 RecordRendererMainEntryHistogram(); 737 RecordRendererMainEntryHistogram();
732 738
733 if (!ShouldLogStartupHistogram()) 739 if (!ShouldLogStartupHistogram())
734 return; 740 return;
735 741
736 base::StackSamplingProfiler::SetProcessMilestone( 742 base::StackSamplingProfiler::SetProcessMilestone(
737 metrics::CallStackProfileMetricsProvider::FIRST_NONEMPTY_PAINT); 743 metrics::CallStackProfileMetricsProvider::FIRST_NONEMPTY_PAINT);
738 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( 744 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT(
739 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint2", 745 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint2",
740 g_process_creation_ticks.Get(), now); 746 g_process_creation_ticks.Get(), ticks);
741 UMA_HISTOGRAM_WITH_TEMPERATURE( 747 UMA_HISTOGRAM_WITH_TEMPERATURE(
742 UMA_HISTOGRAM_LONG_TIMES_100, 748 UMA_HISTOGRAM_LONG_TIMES_100,
743 "Startup.BrowserMessageLoopStart.To.NonEmptyPaint2", 749 "Startup.BrowserMessageLoopStart.To.NonEmptyPaint2",
744 now - g_message_loop_start_ticks.Get()); 750 ticks - g_message_loop_start_ticks.Get());
745 751
746 UMA_HISTOGRAM_WITH_TEMPERATURE( 752 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT(
gab 2017/06/02 18:31:33 Let's not bother with "AND_SAME_VERSION_COUNT" (we
747 UMA_HISTOGRAM_LONG_TIMES_100, 753 UMA_HISTOGRAM_LONG_TIMES_100,
748 "Startup.FirstWebContents.RenderProcessHostInit.ToNonEmptyPaint", 754 "Startup.FirstWebContents.RenderProcessHostInit.ToNonEmptyPaint",
749 now - render_process_host_init_time); 755 g_first_render_process_host_init_ticks.Get(), ticks);
750 } 756 }
751 757
752 void RecordFirstWebContentsMainNavigationStart(base::TimeTicks ticks, 758 void RecordFirstWebContentsMainNavigationStart(base::TimeTicks ticks,
753 WebContentsWorkload workload) { 759 WebContentsWorkload workload) {
754 static bool is_first_call = true; 760 static bool is_first_call = true;
755 if (!is_first_call || ticks.is_null()) 761 if (!is_first_call || ticks.is_null())
756 return; 762 return;
757 is_first_call = false; 763 is_first_call = false;
758 if (!ShouldLogStartupHistogram()) 764 if (!ShouldLogStartupHistogram())
759 return; 765 return;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 UMA_HISTOGRAM_LONG_TIMES_100, 833 UMA_HISTOGRAM_LONG_TIMES_100,
828 "Startup.BrowserWindow.FirstPaint.CompositingEnded", 834 "Startup.BrowserWindow.FirstPaint.CompositingEnded",
829 g_process_creation_ticks.Get(), ticks); 835 g_process_creation_ticks.Get(), ticks);
830 } 836 }
831 837
832 base::TimeTicks MainEntryPointTicks() { 838 base::TimeTicks MainEntryPointTicks() {
833 return g_browser_main_entry_point_ticks.Get(); 839 return g_browser_main_entry_point_ticks.Get();
834 } 840 }
835 841
836 } // namespace startup_metric_utils 842 } // namespace startup_metric_utils
OLDNEW
« no previous file with comments | « components/startup_metric_utils/browser/startup_metric_utils.h ('k') | content/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698