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

Unified Diff: base/profiler/scoped_profile.h

Issue 2695833004: Use TRACK_RUN_IN_THIS_SCOPED_REGION for heap profiler (Closed)
Patch Set: nit. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/profiler/scoped_profile.h
diff --git a/base/profiler/scoped_profile.h b/base/profiler/scoped_profile.h
index 657150a0f18dce184cd814dfa08eea8af7c439bc..fd6d056cfe95bbfc55f914880fbd16a8ec3323a1 100644
--- a/base/profiler/scoped_profile.h
+++ b/base/profiler/scoped_profile.h
@@ -16,6 +16,7 @@
#include "base/location.h"
#include "base/macros.h"
#include "base/profiler/tracked_time.h"
+#include "base/trace_event/heap_profiler.h"
#include "base/tracked_objects.h"
#define PASTE_LINE_NUMBER_ON_NAME(name, line) name##line
@@ -23,21 +24,30 @@
#define LINE_BASED_VARIABLE_NAME_FOR_PROFILING \
PASTE_LINE_NUMBER_ON_NAME(some_profiler_variable_, __LINE__)
+#define LINE_BASED_VARIABLE_NAME_FOR_HEAP_PROFILING \
dcheng 2017/02/15 08:12:44 Do we need a new macro for this? Seems like the on
ssid 2017/02/15 18:59:47 Um, I can't use the same macro twice in TRACK_RUN_
dcheng 2017/02/15 19:14:25 Can we use __COUNTER__ to get around that problem?
ssid 2017/02/15 19:35:53 I replaced with __COUNTER__ and then realized that
+ PASTE_LINE_NUMBER_ON_NAME(heap_profiler_variable_, __LINE__)
+
// Defines the containing scope as a profiled region. This allows developers to
// profile their code and see results on their about:profiler page, as well as
-// on the UMA dashboard.
+// on the UMA dashboard and heap profiler.
#define TRACK_RUN_IN_THIS_SCOPED_REGION(dispatch_function_name) \
+ const ::tracked_objects::Location& location = \
+ FROM_HERE_WITH_EXPLICIT_FUNCTION(#dispatch_function_name); \
+ TRACE_HEAP_PROFILER_API_SCOPED_TASK_EXECUTION \
+ LINE_BASED_VARIABLE_NAME_FOR_HEAP_PROFILING(location.file_name()); \
::tracked_objects::ScopedProfile LINE_BASED_VARIABLE_NAME_FOR_PROFILING( \
- FROM_HERE_WITH_EXPLICIT_FUNCTION(#dispatch_function_name), \
- ::tracked_objects::ScopedProfile::ENABLED)
+ location, ::tracked_objects::ScopedProfile::ENABLED)
// Same as TRACK_RUN_IN_THIS_SCOPED_REGION except that there's an extra param
// which is concatenated with the function name for better filtering.
#define TRACK_SCOPED_REGION(category_name, dispatch_function_name) \
+ const ::tracked_objects::Location& location = \
+ FROM_HERE_WITH_EXPLICIT_FUNCTION("[" category_name \
+ "]" dispatch_function_name); \
+ TRACE_HEAP_PROFILER_API_SCOPED_TASK_EXECUTION \
+ LINE_BASED_VARIABLE_NAME_FOR_HEAP_PROFILING(location.file_name()); \
::tracked_objects::ScopedProfile LINE_BASED_VARIABLE_NAME_FOR_PROFILING( \
- FROM_HERE_WITH_EXPLICIT_FUNCTION( \
- "[" category_name "]" dispatch_function_name), \
- ::tracked_objects::ScopedProfile::ENABLED)
+ location, ::tracked_objects::ScopedProfile::ENABLED)
namespace tracked_objects {
class Births;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698