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

Side by Side Diff: chrome/common/startup_metric_utils.h

Issue 11785014: Record metrics for slow startups (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix review comments. Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CHROME_COMMON_STARTUP_METRIC_UTILS_H_ 5 #ifndef CHROME_COMMON_STARTUP_METRIC_UTILS_H_
6 #define CHROME_COMMON_STARTUP_METRIC_UTILS_H_ 6 #define CHROME_COMMON_STARTUP_METRIC_UTILS_H_
7 7
8 #include <string>
9
8 #include "base/time.h" 10 #include "base/time.h"
9 11
10 // Utility functions to support metric collection for browser startup. 12 // Utility functions to support metric collection for browser startup.
11 13
12 namespace startup_metric_utils { 14 namespace startup_metric_utils {
13 15
14 // Returns true if any UI other than the browser window has been displayed 16 // Returns true if any UI other than the browser window has been displayed
15 // so far. Useful to test if UI has been displayed before the first browser 17 // so far. Useful to test if UI has been displayed before the first browser
16 // window was shown, which would invalidate any surrounding timing metrics. 18 // window was shown, which would invalidate any surrounding timing metrics.
17 bool WasNonBrowserUIDisplayed(); 19 bool WasNonBrowserUIDisplayed();
18 20
19 // Call this when displaying UI that might potentially delay the appearance 21 // Call this when displaying UI that might potentially delay the appearance
20 // of the initial browser window on Chrome startup. 22 // of the initial browser window on Chrome startup.
21 // 23 //
22 // Note on usage: This function is idempotent and its overhead is low enough 24 // Note on usage: This function is idempotent and its overhead is low enough
23 // in comparison with UI display that it's OK to call it on every 25 // in comparison with UI display that it's OK to call it on every
24 // UI invocation regardless of whether the browser window has already 26 // UI invocation regardless of whether the browser window has already
25 // been displayed or not. 27 // been displayed or not.
26 void SetNonBrowserUIDisplayed(); 28 void SetNonBrowserUIDisplayed();
27 29
28 // Call this as early as possible in the startup process to record a 30 // Call this as early as possible in the startup process to record a
29 // timestamp. 31 // timestamp.
30 void RecordMainEntryPointTime(); 32 void RecordMainEntryPointTime();
31 33
32 // Return the time recorded by RecordMainEntryPointTime(). 34 // Called just before the message loop is about to start. Entry point to record
33 const base::Time MainEntryStartTime(); 35 // startup stats.
36 void OnBrowserStartupComplete();
37
38 // Scoper that records the time period before it's destructed in a histogram
39 // with the given name. The histogram is only recorded for slow chrome startups.
40 // Useful for trying to figure out what parts of Chrome cause slow startup.
41 class ScopedSlowStartupUMA {
42 public:
43 explicit ScopedSlowStartupUMA(const std::string& histogram_name)
44 : start_time_(base::TimeTicks::Now()),
sky 2013/01/14 21:54:11 nit: indentation is off here.
45 histogram_name_(histogram_name) {}
46
47 ~ScopedSlowStartupUMA();
48
49 private:
50 base::TimeTicks start_time_;
sky 2013/01/14 21:54:11 nit: const on both of these.
51 std::string histogram_name_;
52
53 DISALLOW_COPY_AND_ASSIGN(ScopedSlowStartupUMA);
54 };
34 55
35 } // namespace startup_metric_utils 56 } // namespace startup_metric_utils
36 57
37 #endif // CHROME_COMMON_STARTUP_METRIC_UTILS_H_ 58 #endif // CHROME_COMMON_STARTUP_METRIC_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698