OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 BASE_PROFILER_SCOPED_TRACKER_H_ | 5 #ifndef BASE_PROFILER_SCOPED_TRACKER_H_ |
6 #define BASE_PROFILER_SCOPED_TRACKER_H_ | 6 #define BASE_PROFILER_SCOPED_TRACKER_H_ |
7 | 7 |
8 //------------------------------------------------------------------------------ | 8 //------------------------------------------------------------------------------ |
9 // Utilities for temporarily instrumenting code to dig into issues that were | 9 // Utilities for temporarily instrumenting code to dig into issues that were |
10 // found using profiler data. | 10 // found using profiler data. |
11 | 11 |
12 #include "base/base_export.h" | 12 #include "base/base_export.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/profiler/scoped_profile.h" | 14 #include "base/profiler/scoped_profile.h" |
15 | 15 |
16 namespace tracked_objects { | 16 namespace tracked_objects { |
17 | 17 |
18 // ScopedTracker instruments a region within the code if the instrumentation is | 18 // ScopedTracker instruments a region within the code if the instrumentation is |
19 // enabled. It can be used, for example, to find out if a source of jankiness is | 19 // enabled. It can be used, for example, to find out if a source of jankiness is |
20 // inside the instrumented code region. | 20 // inside the instrumented code region. |
21 // Details: | |
22 // 1. This class creates a task (like ones created by PostTask calls or IPC | |
23 // message handlers). This task can be seen in chrome://profiler and is sent as | |
24 // a part of profiler data to the UMA server. See profiler_event.proto. | |
25 // 2. That task extends from the object's constructor to its destructor | |
26 // executions. | |
27 // 3. The execution time associated with the task is the wallclock time between | |
28 // its constructor and destructor, minus wallclock times of directly nested | |
29 // tasks. | |
mmenke
2014/11/03 16:19:15
Ahh...This is the important detail I was really co
| |
30 // 4. Task creation that this class utilizes was highly optimized by jar@. | |
31 // 5. The class doesn't create a task unless this was enabled for the current | |
32 // process. Search for ScopedTracker::Enable for the current list of processes | |
33 // and channels where it's activated. | |
34 // 6. The class is designed for temporarily instrumenting code to find | |
35 // performance problems, after which the instrumentation has to be removed. | |
36 // However, in rare cases it might be added permanently, as an exception. | |
21 class BASE_EXPORT ScopedTracker { | 37 class BASE_EXPORT ScopedTracker { |
22 public: | 38 public: |
23 ScopedTracker(const Location& location); | 39 ScopedTracker(const Location& location); |
24 | 40 |
25 // Enables instrumentation for the remainder of the current process' life. If | 41 // Enables instrumentation for the remainder of the current process' life. If |
26 // this function is not called, all profiler instrumentations are no-ops. | 42 // this function is not called, all profiler instrumentations are no-ops. |
27 static void Enable(); | 43 static void Enable(); |
28 | 44 |
29 private: | 45 private: |
30 const ScopedProfile scoped_profile_; | 46 const ScopedProfile scoped_profile_; |
31 | 47 |
32 DISALLOW_COPY_AND_ASSIGN(ScopedTracker); | 48 DISALLOW_COPY_AND_ASSIGN(ScopedTracker); |
33 }; | 49 }; |
34 | 50 |
35 } // namespace tracked_objects | 51 } // namespace tracked_objects |
36 | 52 |
37 #endif // BASE_PROFILER_SCOPED_TRACKER_H_ | 53 #endif // BASE_PROFILER_SCOPED_TRACKER_H_ |
OLD | NEW |