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 #ifndef COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ | 5 #ifndef COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ |
6 #define COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ | 6 #define COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 enum StartupTemperature { | 27 enum StartupTemperature { |
28 // The startup was a cold start: nearly all of the binaries and resources were | 28 // The startup was a cold start: nearly all of the binaries and resources were |
29 // brought into memory using hard faults. | 29 // brought into memory using hard faults. |
30 COLD_STARTUP_TEMPERATURE = 0, | 30 COLD_STARTUP_TEMPERATURE = 0, |
31 // The startup was a warm start: the binaries and resources were mostly | 31 // The startup was a warm start: the binaries and resources were mostly |
32 // already resident in memory and effectively no hard faults were observed. | 32 // already resident in memory and effectively no hard faults were observed. |
33 WARM_STARTUP_TEMPERATURE = 1, | 33 WARM_STARTUP_TEMPERATURE = 1, |
34 // The startup type couldn't quite be classified as warm or cold, but rather | 34 // The startup type couldn't quite be classified as warm or cold, but rather |
35 // was somewhere in between. | 35 // was somewhere in between. |
36 LUKEWARM_STARTUP_TEMPERATURE = 2, | 36 LUKEWARM_STARTUP_TEMPERATURE = 2, |
37 // This must be after all meaningful values. | 37 // This must be after all meaningful values and be equal to the last one. |
38 STARTUP_TEMPERATURE_COUNT, | 38 STARTUP_TEMPERATURE_MAX = LUKEWARM_STARTUP_TEMPERATURE, |
39 // Startup temperature wasn't yet determined. | 39 // Startup temperature wasn't yet determined. |
40 UNDETERMINED_STARTUP_TEMPERATURE | 40 UNDETERMINED_STARTUP_TEMPERATURE |
41 }; | 41 }; |
42 | 42 |
43 #if defined(OS_WIN) | 43 #if defined(OS_WIN) |
44 // Gets the hard fault count of the current process through |hard_fault_count|. | 44 // Gets the hard fault count of the current process through |hard_fault_count|. |
45 // Returns true on success. | 45 // Returns true on success. |
46 bool GetHardFaultCountForCurrentProcess(uint32_t* hard_fault_count); | 46 bool GetHardFaultCountForCurrentProcess(uint32_t* hard_fault_count); |
47 #endif // defined(OS_WIN) | 47 #endif // defined(OS_WIN) |
48 | 48 |
(...skipping 20 matching lines...) Expand all Loading... |
69 // On Android, the entry point time is the time at which the Java code starts. | 69 // On Android, the entry point time is the time at which the Java code starts. |
70 // In Mojo, the entry point time is the time at which the shell starts. | 70 // In Mojo, the entry point time is the time at which the shell starts. |
71 void RecordMainEntryPointTime(const base::Time& time); | 71 void RecordMainEntryPointTime(const base::Time& time); |
72 | 72 |
73 // Call this with the time when the executable is loaded and main() is entered. | 73 // Call this with the time when the executable is loaded and main() is entered. |
74 // Can be different from |RecordMainEntryPointTime| when the startup process is | 74 // Can be different from |RecordMainEntryPointTime| when the startup process is |
75 // contained in a separate dll, such as with chrome.exe / chrome.dll on Windows. | 75 // contained in a separate dll, such as with chrome.exe / chrome.dll on Windows. |
76 void RecordExeMainEntryPointTime(const base::Time& time); | 76 void RecordExeMainEntryPointTime(const base::Time& time); |
77 | 77 |
78 // Call this with the time recorded just before the message loop is started. | 78 // Call this with the time recorded just before the message loop is started. |
79 // |is_first_run| - is the current launch part of a first run. | 79 // |is_first_run| - is the current launch part of a first run. |pref_service| |
| 80 // will be used to store state for stats that span multiple startups and its |
| 81 // data should thus be consistent from one startup to the next. |
80 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, | 82 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, |
81 bool is_first_run); | 83 bool is_first_run, |
82 | 84 PrefService* pref_service); |
83 // Logs the Startup.TimeSinceLastStartup histogram. Obtains the timestamp of the | |
84 // last startup from |pref_service| and overwrites it with the timestamp of the | |
85 // current startup. If the startup temperature has been set by | |
86 // RecordBrowserMainMessageLoopStart, the time since last startup is also logged | |
87 // to an histogram suffixed with the startup temperature. | |
88 void RecordTimeSinceLastStartup(PrefService* pref_service); | |
89 | |
90 // Logs the Startup.SameVersionStartupCount histogram. Relies on |pref_service| | |
91 // to know information about the previous startups and store information for | |
92 // future ones. | |
93 void RecordStartupCount(PrefService* pref_service); | |
94 | 85 |
95 // Call this with the time when the first browser window became visible. | 86 // Call this with the time when the first browser window became visible. |
96 void RecordBrowserWindowDisplay(const base::TimeTicks& ticks); | 87 void RecordBrowserWindowDisplay(const base::TimeTicks& ticks); |
97 | 88 |
98 // Call this with the time delta that the browser spent opening its tabs. | 89 // Call this with the time delta that the browser spent opening its tabs. |
99 void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta); | 90 void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta); |
100 | 91 |
101 // Call this with a renderer main entry time. The value provided for the first | 92 // Call this with a renderer main entry time. The value provided for the first |
102 // call to this function is used to compute | 93 // call to this function is used to compute |
103 // Startup.LoadTime.BrowserMainToRendererMain. Further calls to this | 94 // Startup.LoadTime.BrowserMainToRendererMain. Further calls to this |
(...skipping 22 matching lines...) Expand all Loading... |
126 base::TimeTicks MainEntryPointTicks(); | 117 base::TimeTicks MainEntryPointTicks(); |
127 | 118 |
128 // Returns the startup type. This is only currently supported on the Windows | 119 // Returns the startup type. This is only currently supported on the Windows |
129 // platform and will simply return UNCERTAIN_STARTUP_TYPE on other platforms. | 120 // platform and will simply return UNCERTAIN_STARTUP_TYPE on other platforms. |
130 // This is only valid after a call to RecordBrowserMainMessageLoopStart(). | 121 // This is only valid after a call to RecordBrowserMainMessageLoopStart(). |
131 StartupTemperature GetStartupTemperature(); | 122 StartupTemperature GetStartupTemperature(); |
132 | 123 |
133 } // namespace startup_metric_utils | 124 } // namespace startup_metric_utils |
134 | 125 |
135 #endif // COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ | 126 #endif // COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ |
OLD | NEW |