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

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

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « base/observer_list_unittest.cc ('k') | base/profiler/scoped_profile.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 #define PASTE_LINE_NUMBER_ON_NAME(name, line) name##line 20 #define PASTE_LINE_NUMBER_ON_NAME(name, line) name##line
21 21
22 #define LINE_BASED_VARIABLE_NAME_FOR_PROFILING \ 22 #define LINE_BASED_VARIABLE_NAME_FOR_PROFILING \
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 31 ::tracked_objects::ScopedProfile::ENABLED)
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 38 // Mode of operation. Specifies whether ScopedProfile should be a no-op or
39 // needs to create and tally a task. 39 // needs to create and tally a task.
40 enum Mode { 40 enum Mode {
41 DISABLED, // Do nothing. 41 DISABLED, // Do nothing.
42 ENABLED // Create and tally a task. 42 ENABLED // Create and tally a task.
43 }; 43 };
44 44
45 // TODO(vadimt): Remove this constructor.
46 explicit ScopedProfile(const Location& location);
47 ScopedProfile(const Location& location, Mode mode); 45 ScopedProfile(const Location& location, Mode mode);
48 ~ScopedProfile(); 46 ~ScopedProfile();
49 47
50 private: 48 private:
51 Births* birth_; // Place in code where tracking started. 49 Births* birth_; // Place in code where tracking started.
52 TaskStopwatch stopwatch_; 50 TaskStopwatch stopwatch_;
53 51
54 DISALLOW_COPY_AND_ASSIGN(ScopedProfile); 52 DISALLOW_COPY_AND_ASSIGN(ScopedProfile);
55 }; 53 };
56 54
57 } // namespace tracked_objects 55 } // namespace tracked_objects
58 56
59 #endif // BASE_PROFILER_SCOPED_PROFILE_H_ 57 #endif // BASE_PROFILER_SCOPED_PROFILE_H_
OLDNEW
« no previous file with comments | « base/observer_list_unittest.cc ('k') | base/profiler/scoped_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698