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

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

Issue 1124763003: Update from https://crrev.com/327068 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: update nacl, buildtools, fix display_change_notifier_unittest Created 5 years, 7 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 (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
(...skipping 12 matching lines...) Expand all
23 PASTE_LINE_NUMBER_ON_NAME(some_profiler_variable_, __LINE__) 23 PASTE_LINE_NUMBER_ON_NAME(some_profiler_variable_, __LINE__)
24 24
25 // Defines the containing scope as a profiled region. This allows developers to 25 // Defines the containing scope as a profiled region. This allows developers to
26 // profile their code and see results on their about:profiler page, as well as 26 // profile their code and see results on their about:profiler page, as well as
27 // on the UMA dashboard. 27 // on the UMA dashboard.
28 #define TRACK_RUN_IN_THIS_SCOPED_REGION(dispatch_function_name) \ 28 #define TRACK_RUN_IN_THIS_SCOPED_REGION(dispatch_function_name) \
29 ::tracked_objects::ScopedProfile LINE_BASED_VARIABLE_NAME_FOR_PROFILING( \ 29 ::tracked_objects::ScopedProfile LINE_BASED_VARIABLE_NAME_FOR_PROFILING( \
30 FROM_HERE_WITH_EXPLICIT_FUNCTION(#dispatch_function_name), \ 30 FROM_HERE_WITH_EXPLICIT_FUNCTION(#dispatch_function_name), \
31 ::tracked_objects::ScopedProfile::ENABLED) 31 ::tracked_objects::ScopedProfile::ENABLED)
32 32
33 // Same as TRACK_RUN_IN_THIS_SCOPED_REGION except that there's an extra param
34 // which is concatenated with the function name for better filtering.
35 #define TRACK_SCOPED_REGION(category_name, dispatch_function_name) \
36 ::tracked_objects::ScopedProfile LINE_BASED_VARIABLE_NAME_FOR_PROFILING( \
37 FROM_HERE_WITH_EXPLICIT_FUNCTION( \
38 "[" category_name "]" dispatch_function_name), \
39 ::tracked_objects::ScopedProfile::ENABLED)
40
33 namespace tracked_objects { 41 namespace tracked_objects {
34 class Births; 42 class Births;
35 43
36 class BASE_EXPORT ScopedProfile { 44 class BASE_EXPORT ScopedProfile {
37 public: 45 public:
38 // Mode of operation. Specifies whether ScopedProfile should be a no-op or 46 // Mode of operation. Specifies whether ScopedProfile should be a no-op or
39 // needs to create and tally a task. 47 // needs to create and tally a task.
40 enum Mode { 48 enum Mode {
41 DISABLED, // Do nothing. 49 DISABLED, // Do nothing.
42 ENABLED // Create and tally a task. 50 ENABLED // Create and tally a task.
43 }; 51 };
44 52
45 ScopedProfile(const Location& location, Mode mode); 53 ScopedProfile(const Location& location, Mode mode);
46 ~ScopedProfile(); 54 ~ScopedProfile();
47 55
48 private: 56 private:
49 Births* birth_; // Place in code where tracking started. 57 Births* birth_; // Place in code where tracking started.
50 TaskStopwatch stopwatch_; 58 TaskStopwatch stopwatch_;
51 59
52 DISALLOW_COPY_AND_ASSIGN(ScopedProfile); 60 DISALLOW_COPY_AND_ASSIGN(ScopedProfile);
53 }; 61 };
54 62
55 } // namespace tracked_objects 63 } // namespace tracked_objects
56 64
57 #endif // BASE_PROFILER_SCOPED_PROFILE_H_ 65 #endif // BASE_PROFILER_SCOPED_PROFILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698