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

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') | 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) 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) \
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 {
778 public:
779 TraceEventSamplingState0Scope(const char* category_and_name)
780 {
781 previousState0_ = TraceEventSamplingState0Scope::current();
782 TraceEventSamplingState0Scope::forceCurrent(category_and_name);
783 }
784
785 ~TraceEventSamplingState0Scope()
786 {
787 TraceEventSamplingState0Scope::forceCurrent(previousState0_);
788 }
789
790 static inline const char* current()
scottmg 2013/07/03 02:16:10 In chromium code, these should be Current()
haraken 2013/07/03 02:38:50 Done.
791 {
792 return reinterpret_cast<const char*>(TRACE_EVENT_API_ATOMIC_LOAD(
793 TRACE_EVENT_API_THREAD_BUCKET(0)));
794 }
795
796 static inline void forceCurrent(const char* category_and_name)
scottmg 2013/07/03 02:16:10 and ForceCurrent. Maybe just "Set" would be fine t
haraken 2013/07/03 02:38:50 Done.
797 {
798 TRACE_EVENT_API_ATOMIC_STORE(
799 TRACE_EVENT_API_THREAD_BUCKET(0),
800 reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>(
801 const_cast<char*>(category_and_name)));
802 }
803
804 private:
805 const char* previousState0_;
scottmg 2013/07/03 02:16:10 and previous_state0_
haraken 2013/07/03 02:38:50 Done.
806 };
766 #endif 807 #endif
767 808
768 //////////////////////////////////////////////////////////////////////////////// 809 ////////////////////////////////////////////////////////////////////////////////
769 810
770 // Implementation detail: trace event macros create temporary variables 811 // Implementation detail: trace event macros create temporary variables
771 // to keep instrumentation overhead low. These macros give each temporary 812 // to keep instrumentation overhead low. These macros give each temporary
772 // variable a unique name based on the line number to prevent name collissions. 813 // variable a unique name based on the line number to prevent name collissions.
773 #define INTERNAL_TRACE_EVENT_UID3(a,b) \ 814 #define INTERNAL_TRACE_EVENT_UID3(a,b) \
774 trace_event_unique_##a##b 815 trace_event_unique_##a##b
775 #define INTERNAL_TRACE_EVENT_UID2(a,b) \ 816 #define INTERNAL_TRACE_EVENT_UID2(a,b) \
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 const char* name_; 1508 const char* name_;
1468 IDType id_; 1509 IDType id_;
1469 1510
1470 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); 1511 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject);
1471 }; 1512 };
1472 1513
1473 } // namespace debug 1514 } // namespace debug
1474 } // namespace base 1515 } // namespace base
1475 1516
1476 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */ 1517 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */
OLDNEW
« no previous file with comments | « no previous file | base/debug/trace_event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698