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

Side by Side Diff: base/profiler/scoped_profile.h

Issue 600213002: Instrumenting OnExtensionAddListener observer invocation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: brettw@ comment Created 6 years, 2 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
« no previous file with comments | « no previous file | extensions/browser/event_router.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 5
6 #ifndef BASE_PROFILER_SCOPED_PROFILE_H_ 6 #ifndef BASE_PROFILER_SCOPED_PROFILE_H_
7 #define BASE_PROFILER_SCOPED_PROFILE_H_ 7 #define BASE_PROFILER_SCOPED_PROFILE_H_
8 8
9 //------------------------------------------------------------------------------ 9 //------------------------------------------------------------------------------
10 // ScopedProfile provides basic helper functions for profiling a short 10 // ScopedProfile provides basic helper functions for profiling a short
11 // region of code within a scope. It is separate from the related ThreadData 11 // region of code within a scope. It is separate from the related ThreadData
12 // class so that it can be included without much other cruft, and provide the 12 // class so that it can be included without much other cruft, and provide the
13 // macros listed below. 13 // macros listed below.
14 14
15 #include "base/base_export.h" 15 #include "base/base_export.h"
16 #include "base/location.h" 16 #include "base/location.h"
17 #include "base/profiler/tracked_time.h" 17 #include "base/profiler/tracked_time.h"
18 #include "base/tracked_objects.h" 18 #include "base/tracked_objects.h"
19 19
20 #if defined(GOOGLE_CHROME_BUILD)
21
22 // We don't ship these profiled regions. This is for developer builds only.
23 // It allows developers to do some profiling of their code, and see results on
24 // their about:profiler page.
25 #define TRACK_RUN_IN_THIS_SCOPED_REGION_FOR_DEVELOPER_BUILDS(scope_name) \
26 ((void)0)
27
28 #else
29
30 #define TRACK_RUN_IN_THIS_SCOPED_REGION_FOR_DEVELOPER_BUILDS(scope_name) \
31 ::tracked_objects::ScopedProfile LINE_BASED_VARIABLE_NAME_FOR_PROFILING( \
32 FROM_HERE_WITH_EXPLICIT_FUNCTION(#scope_name))
33
34 #endif
35
36
37
38 #define PASTE_LINE_NUMBER_ON_NAME(name, line) name##line 20 #define PASTE_LINE_NUMBER_ON_NAME(name, line) name##line
39 21
40 #define LINE_BASED_VARIABLE_NAME_FOR_PROFILING \ 22 #define LINE_BASED_VARIABLE_NAME_FOR_PROFILING \
41 PASTE_LINE_NUMBER_ON_NAME(some_profiler_variable_, __LINE__) 23 PASTE_LINE_NUMBER_ON_NAME(some_profiler_variable_, __LINE__)
42 24
43 #define TRACK_RUN_IN_IPC_HANDLER(dispatch_function_name) \ 25 // Defines the containing scope as a profiled region. This allows developers to
44 ::tracked_objects::ScopedProfile some_tracking_variable_name( \ 26 // profile their code and see results on their about:profiler page, as well as
27 // on the UMA dashboard.
28 #define TRACK_RUN_IN_THIS_SCOPED_REGION(dispatch_function_name) \
29 ::tracked_objects::ScopedProfile LINE_BASED_VARIABLE_NAME_FOR_PROFILING( \
45 FROM_HERE_WITH_EXPLICIT_FUNCTION(#dispatch_function_name)) 30 FROM_HERE_WITH_EXPLICIT_FUNCTION(#dispatch_function_name))
46 31
47 32
48 namespace tracked_objects { 33 namespace tracked_objects {
49 class Births; 34 class Births;
50 35
51 class BASE_EXPORT ScopedProfile { 36 class BASE_EXPORT ScopedProfile {
52 public: 37 public:
53 explicit ScopedProfile(const Location& location); 38 explicit ScopedProfile(const Location& location);
54 ~ScopedProfile(); 39 ~ScopedProfile();
55 40
56 // Stop tracing prior to the end destruction of the instance. 41 // Stop tracing prior to the end destruction of the instance.
57 void StopClockAndTally(); 42 void StopClockAndTally();
58 43
59 private: 44 private:
60 Births* birth_; // Place in code where tracking started. 45 Births* birth_; // Place in code where tracking started.
61 TaskStopwatch stopwatch_; 46 TaskStopwatch stopwatch_;
62 47
63 DISALLOW_COPY_AND_ASSIGN(ScopedProfile); 48 DISALLOW_COPY_AND_ASSIGN(ScopedProfile);
64 }; 49 };
65 50
66 } // namespace tracked_objects 51 } // namespace tracked_objects
67 52
68 #endif // BASE_PROFILER_SCOPED_PROFILE_H_ 53 #endif // BASE_PROFILER_SCOPED_PROFILE_H_
OLDNEW
« no previous file with comments | « no previous file | extensions/browser/event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698