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

Side by Side Diff: base/debug/trace_event.h

Issue 18587004: Add a sampling tracing to RenderWidget::DoDeferredUpdate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/debug/trace_event_unittest.cc » ('j') | content/renderer/render_widget.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This header file defines the set of trace_event macros without specifying 5 // This header file defines the set of trace_event macros without specifying
6 // how the events actually get collected and stored. If you need to expose trace 6 // how the events actually get collected and stored. If you need to expose trace
7 // events to some other universe, you can copy-and-paste this file as well as 7 // events to some other universe, you can copy-and-paste this file as well as
8 // trace_event.h, modifying the macros contained there as necessary for the 8 // trace_event.h, modifying the macros contained there as necessary for the
9 // target platform. The end result is that multiple libraries can funnel events 9 // target platform. The end result is that multiple libraries can funnel events
10 // through to a shared trace event collector. 10 // through to a shared trace event collector.
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ 292 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \
293 category_group, name, TRACE_EVENT_FLAG_COPY | scope, \ 293 category_group, name, TRACE_EVENT_FLAG_COPY | scope, \
294 arg1_name, arg1_val, arg2_name, arg2_val) 294 arg1_name, arg1_val, arg2_name, arg2_val)
295 295
296 // Sets the current sample state to the given category and name (both must be 296 // Sets the current sample state to the given category and name (both must be
297 // constant strings). These states are intended for a sampling profiler. 297 // constant strings). These states are intended for a sampling profiler.
298 // Implementation note: we store category and name together because we don't 298 // Implementation note: we store category and name together because we don't
299 // want the inconsistency/expense of storing two pointers. 299 // want the inconsistency/expense of storing two pointers.
300 // |thread_bucket| is [0..2] and is used to statically isolate samples in one 300 // |thread_bucket| is [0..2] and is used to statically isolate samples in one
301 // thread from others. 301 // thread from others.
302 #define TRACE_EVENT_SAMPLE_STATE(thread_bucket, category, name) \ 302 #define TRACE_EVENT_SAMPLING_STATE0(category, name) \
nduca 2013/07/03 05:34:24 can you provide some explanation on why the rename
haraken 2013/07/03 07:33:15 Makes sense. I renamed it to TARCE_EVENT_SET_SAMPL
303 TRACE_EVENT_API_ATOMIC_STORE( \ 303 INTERNAL_TRACE_EVENT_SAMPLING_STATE(0, category, name)
304 TRACE_EVENT_API_THREAD_BUCKET(thread_bucket), \ 304 #define TRACE_EVENT_SAMPLING_STATE1(category, name) \
305 INTERNAL_TRACE_EVENT_SAMPLING_STATE(1, category, name)
306 #define TRACE_EVENT_SAMPLING_STATE2(category, name) \
307 INTERNAL_TRACE_EVENT_SAMPLING_STATE(2, category, name)
308
309 #define INTERNAL_TRACE_EVENT_SAMPLING_STATE(thread_bucket, category, name) \
310 TRACE_EVENT_API_ATOMIC_STORE( \
311 TRACE_EVENT_API_THREAD_BUCKET(thread_bucket), \
305 reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>(category "\0" name)); 312 reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>(category "\0" name));
306 313
307 // Records a single BEGIN event called "name" immediately, with 0, 1 or 2 314 // Records a single BEGIN event called "name" immediately, with 0, 1 or 2
308 // associated arguments. If the category is not enabled, then this 315 // associated arguments. If the category is not enabled, then this
309 // does nothing. 316 // does nothing.
310 // - category and name strings must have application lifetime (statics or 317 // - category and name strings must have application lifetime (statics or
311 // literals). They may not include " chars. 318 // literals). They may not include " chars.
312 #define TRACE_EVENT_BEGIN0(category_group, name) \ 319 #define TRACE_EVENT_BEGIN0(category_group, name) \
313 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ 320 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \
314 category_group, name, TRACE_EVENT_FLAG_NONE) 321 category_group, name, TRACE_EVENT_FLAG_NONE)
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 #define TRACE_EVENT_API_CLASS_EXPORT BASE_EXPORT 763 #define TRACE_EVENT_API_CLASS_EXPORT BASE_EXPORT
757 764
758 // Not supported in split-dll build. http://crbug.com/237249 765 // Not supported in split-dll build. http://crbug.com/237249
759 #if !defined(CHROME_SPLIT_DLL) 766 #if !defined(CHROME_SPLIT_DLL)
760 // The thread buckets for the sampling profiler. 767 // The thread buckets for the sampling profiler.
761 TRACE_EVENT_API_CLASS_EXPORT extern TRACE_EVENT_API_ATOMIC_WORD g_trace_state0; 768 TRACE_EVENT_API_CLASS_EXPORT extern TRACE_EVENT_API_ATOMIC_WORD g_trace_state0;
762 TRACE_EVENT_API_CLASS_EXPORT extern TRACE_EVENT_API_ATOMIC_WORD g_trace_state1; 769 TRACE_EVENT_API_CLASS_EXPORT extern TRACE_EVENT_API_ATOMIC_WORD g_trace_state1;
763 TRACE_EVENT_API_CLASS_EXPORT extern TRACE_EVENT_API_ATOMIC_WORD g_trace_state2; 770 TRACE_EVENT_API_CLASS_EXPORT extern TRACE_EVENT_API_ATOMIC_WORD g_trace_state2;
764 #define TRACE_EVENT_API_THREAD_BUCKET(thread_bucket) \ 771 #define TRACE_EVENT_API_THREAD_BUCKET(thread_bucket) \
765 g_trace_state##thread_bucket 772 g_trace_state##thread_bucket
773
774 // TraceEventSamplingState0Scope records the current sampling state
775 // and sets a new sampling state. When the scope exists, it restores
776 // the sampling state having recorded.
777 class TraceEventSamplingState0Scope {
nduca 2013/07/03 05:34:24 Can we templatize this so that this works for 1,2
haraken 2013/07/03 07:33:15 Done.
778 public:
779 TraceEventSamplingState0Scope(const char* category_and_name) {
nduca 2013/07/03 05:34:24 we prefer people not use the scope objects directl
haraken 2013/07/03 07:33:15 Done.
780 previous_state0_ = TraceEventSamplingState0Scope::Current();
781 TraceEventSamplingState0Scope::Set(category_and_name);
782 }
783
784 ~TraceEventSamplingState0Scope() {
785 TraceEventSamplingState0Scope::Set(previous_state0_);
786 }
787
788 static inline const char* Current() {
789 return reinterpret_cast<const char*>(TRACE_EVENT_API_ATOMIC_LOAD(
790 TRACE_EVENT_API_THREAD_BUCKET(0)));
791 }
792
793 static inline void Set(const char* category_and_name) {
794 TRACE_EVENT_API_ATOMIC_STORE(
795 TRACE_EVENT_API_THREAD_BUCKET(0),
796 reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>(
797 const_cast<char*>(category_and_name)));
798 }
799
800 private:
801 const char* previous_state0_;
802 };
766 #endif 803 #endif
767 804
768 //////////////////////////////////////////////////////////////////////////////// 805 ////////////////////////////////////////////////////////////////////////////////
769 806
770 // Implementation detail: trace event macros create temporary variables 807 // Implementation detail: trace event macros create temporary variables
771 // to keep instrumentation overhead low. These macros give each temporary 808 // to keep instrumentation overhead low. These macros give each temporary
772 // variable a unique name based on the line number to prevent name collissions. 809 // variable a unique name based on the line number to prevent name collissions.
773 #define INTERNAL_TRACE_EVENT_UID3(a,b) \ 810 #define INTERNAL_TRACE_EVENT_UID3(a,b) \
774 trace_event_unique_##a##b 811 trace_event_unique_##a##b
775 #define INTERNAL_TRACE_EVENT_UID2(a,b) \ 812 #define INTERNAL_TRACE_EVENT_UID2(a,b) \
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 const char* name_; 1504 const char* name_;
1468 IDType id_; 1505 IDType id_;
1469 1506
1470 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); 1507 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject);
1471 }; 1508 };
1472 1509
1473 } // namespace debug 1510 } // namespace debug
1474 } // namespace base 1511 } // namespace base
1475 1512
1476 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */ 1513 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */
OLDNEW
« no previous file with comments | « no previous file | base/debug/trace_event_unittest.cc » ('j') | content/renderer/render_widget.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698