OLD | NEW |
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 17 matching lines...) Expand all Loading... |
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 | 31 |
32 | 32 |
33 namespace tracked_objects { | 33 namespace tracked_objects { |
34 class Births; | 34 class Births; |
35 | 35 |
36 class BASE_EXPORT ScopedProfile { | 36 class BASE_EXPORT ScopedProfile { |
37 public: | 37 public: |
| 38 // Mode of operation. Specifies whether ScopedProfile should be a no-op or |
| 39 // needs to create and tally a task. |
| 40 enum Mode { |
| 41 DISABLED, // Do nothing. |
| 42 ENABLED // Create and tally a task. |
| 43 }; |
| 44 |
| 45 // TODO(vadimt): Remove this constructor. |
38 explicit ScopedProfile(const Location& location); | 46 explicit ScopedProfile(const Location& location); |
| 47 ScopedProfile(const Location& location, Mode mode); |
39 ~ScopedProfile(); | 48 ~ScopedProfile(); |
40 | 49 |
41 // Stop tracing prior to the end destruction of the instance. | |
42 void StopClockAndTally(); | |
43 | |
44 private: | 50 private: |
45 Births* birth_; // Place in code where tracking started. | 51 Births* birth_; // Place in code where tracking started. |
46 TaskStopwatch stopwatch_; | 52 TaskStopwatch stopwatch_; |
47 | 53 |
48 DISALLOW_COPY_AND_ASSIGN(ScopedProfile); | 54 DISALLOW_COPY_AND_ASSIGN(ScopedProfile); |
49 }; | 55 }; |
50 | 56 |
51 } // namespace tracked_objects | 57 } // namespace tracked_objects |
52 | 58 |
53 #endif // BASE_PROFILER_SCOPED_PROFILE_H_ | 59 #endif // BASE_PROFILER_SCOPED_PROFILE_H_ |
OLD | NEW |