HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
collector.h
Go to the documentation of this file.
1 //
2 // Copyright 2018 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 
25 #ifndef PXR_BASE_TRACE_COLLECTOR_H
26 #define PXR_BASE_TRACE_COLLECTOR_H
27 
28 #include "pxr/pxr.h"
29 
30 #include "pxr/base/trace/api.h"
33 #include "pxr/base/trace/event.h"
34 #include "pxr/base/trace/key.h"
35 #include "pxr/base/trace/threads.h"
36 
38 #include "pxr/base/tf/mallocTag.h"
39 
40 #include "pxr/base/tf/pyTracing.h"
41 
42 #include "pxr/base/tf/singleton.h"
43 #include "pxr/base/tf/refBase.h"
44 #include "pxr/base/tf/refPtr.h"
45 #include "pxr/base/tf/weakBase.h"
46 #include "pxr/base/tf/weakPtr.h"
47 
48 #include "pxr/base/arch/pragmas.h"
49 
50 #include <atomic>
51 #include <string>
52 #include <vector>
53 
54 #include <tbb/spin_mutex.h>
55 
57 
58 class TraceScopeHolder;
59 
62 
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 /// \class TraceCollector
66 ///
67 /// This is a singleton class that records TraceEvent instances and populates
68 /// TraceCollection instances.
69 ///
70 /// All public methods of TraceCollector are safe to call from any thread.
71 class TraceCollector : public TfWeakBase {
72 public:
73 
74  TF_MALLOC_TAG_NEW("Trace", "TraceCollector");
75 
77  using ThisPtr = TraceCollectorPtr;
78 
80 
82 
83  /// Returns the singleton instance.
86  }
87 
89 
90  /// Enables or disables collection of events for DefaultCategory.
91  TRACE_API void SetEnabled(bool isEnabled);
92 
93  /// Returns whether collection of events is enabled for DefaultCategory.
94  static bool IsEnabled() {
95  return (_isEnabled.load(std::memory_order_acquire) == 1);
96  }
97 
98  /// Default Trace category which corresponds to events stored for TRACE_
99  /// macros.
101  /// Returns TraceCategory::Default.
102  static constexpr TraceCategoryId GetId() { return TraceCategory::Default;}
103  /// Returns the result of TraceCollector::IsEnabled.
104  static bool IsEnabled() { return TraceCollector::IsEnabled(); }
105  };
106 
107 #ifdef PXR_PYTHON_SUPPORT_ENABLED
108  /// Returns whether automatic tracing of all python scopes is enabled.
109  bool IsPythonTracingEnabled() const {
110  return _isPythonTracingEnabled.load(std::memory_order_acquire) != 0;
111  }
112 
113  /// Set whether automatic tracing of all python scopes is enabled.
114  TRACE_API void SetPythonTracingEnabled(bool enabled);
115 #endif // PXR_PYTHON_SUPPORT_ENABLED
116 
117  /// Return the overhead cost to measure a scope.
119 
120  /// Clear all pending events from the collector. No TraceCollection will be
121  /// made for these events.
122  TRACE_API void Clear();
123 
124  /// \name Event Recording
125  /// @{
126 
127  /// Record a begin event with \a key if \p Category is enabled.
128  /// A matching end event is expected some time in the future.
129  ///
130  /// If the key is known at compile time \c BeginScope and \c Scope methods
131  /// are preferred because they have lower overhead.
132  /// \returns The TimeStamp of the TraceEvent or 0 if the collector is
133  /// disabled.
134  /// \sa BeginScope \sa Scope
135  template <typename Category = DefaultCategory>
136  TimeStamp BeginEvent(const Key& key) {
137  if (ARCH_LIKELY(!Category::IsEnabled())) {
138  return 0;
139  }
140  return _BeginEvent(key, Category::GetId());
141  }
142 
143  /// Record a begin event with \a key at a specified time if \p Category is
144  /// enabled.
145  /// This version of the method allows the passing of a specific number of
146  /// elapsed milliseconds, \a ms, to use for this event.
147  /// This method is used for testing and debugging code.
148  template <typename Category = DefaultCategory>
149  void BeginEventAtTime(const Key& key, double ms) {
150  if (ARCH_LIKELY(!Category::IsEnabled())) {
151  return;
152  }
153  _BeginEventAtTime(key, ms, Category::GetId());
154  }
155 
156  /// Record an end event with \a key if \p Category is enabled.
157  /// A matching begin event must have preceded this end event.
158  ///
159  /// If the key is known at compile time EndScope and Scope methods are
160  /// preferred because they have lower overhead.
161  /// \returns The TimeStamp of the TraceEvent or 0 if the collector is
162  /// disabled.
163  /// \sa EndScope \sa Scope
164  template <typename Category = DefaultCategory>
165  TimeStamp EndEvent(const Key& key) {
166  if (ARCH_LIKELY(!Category::IsEnabled())) {
167  return 0;
168  }
169  return _EndEvent(key, Category::GetId());
170  }
171 
172  /// Record an end event with \a key at a specified time if \p Category is
173  /// enabled.
174  /// This version of the method allows the passing of a specific number of
175  /// elapsed milliseconds, \a ms, to use for this event.
176  /// This method is used for testing and debugging code.
177  template <typename Category = DefaultCategory>
178  void EndEventAtTime(const Key& key, double ms) {
179  if (ARCH_LIKELY(!Category::IsEnabled())) {
180  return;
181  }
182  _EndEventAtTime(key, ms, Category::GetId());
183  }
184 
185 
186  /// Record a marker event with \a key if \p Category is enabled.
187  /// Unlike begin/end, there is no matching event for marker events
188  ///
189 
190  template <typename Category = DefaultCategory>
191  TimeStamp MarkerEvent(const Key& key) {
192  if (ARCH_LIKELY(!Category::IsEnabled())) {
193  return 0;
194  }
195  return _MarkerEvent(key, Category::GetId());
196  }
197 
198  /// Record a marker event with \a key at a specified time if \p Category is
199  /// enabled.
200  /// This version of the method allows the passing of a specific number of
201  /// elapsed milliseconds, \a ms, to use for this event.
202  /// This method is used for testing and debugging code.
203  template <typename Category = DefaultCategory>
204  void MarkerEventAtTime(const Key& key, double ms) {
205  if (ARCH_LIKELY(!Category::IsEnabled())) {
206  return;
207  }
208  _MarkerEventAtTime(key, ms, Category::GetId());
209  }
210 
211  /// Record a begin event for a scope described by \a key if \p Category is
212  /// enabled.
213  /// It is more efficient to use the \c Scope method than to call both
214  /// \c BeginScope and \c EndScope.
215  /// \sa EndScope \sa Scope
216  template <typename Category = DefaultCategory>
217  void BeginScope(const TraceKey& _key) {
218  if (ARCH_LIKELY(!Category::IsEnabled()))
219  return;
220 
221  _BeginScope(_key, Category::GetId());
222  }
223 
224  /// Record a begin event for a scope described by \a key and a specified
225  /// category and store data arguments if \p Category is enabled.
226  /// The variadic arguments \a args must be an even number of parameters in
227  /// the form TraceKey, Value.
228  /// \sa EndScope \sa Scope \sa StoreData
229  template <typename Category, typename... Args>
231  const TraceKey& key, Args&&... args) {
232  static_assert( sizeof...(Args) %2 == 0,
233  "Data arguments must come in pairs");
234 
235  if (ARCH_LIKELY(!Category::IsEnabled()))
236  return;
237 
238  _PerThreadData *threadData = _GetThreadData();
239  threadData->BeginScope(key, Category::GetId());
240  _StoreDataRec(threadData, Category::GetId(), std::forward<Args>(args)...);
241  }
242 
243  /// Record a begin event for a scope described by \a key and store data
244  /// arguments if \p Category is enabled. The variadic arguments \a args must
245  /// be an even number of parameters in the form TraceKey, Value.
246  /// \sa EndScope \sa Scope \sa StoreData
247  template <typename... Args>
248  void BeginScope(const TraceKey& key, Args&&... args) {
249  static_assert( sizeof...(Args) %2 == 0,
250  "Data arguments must come in pairs");
251 
252  // Explicitly cast to TraceCategoryId so overload resolution choose the
253  // version with a category arguement.
254  BeginScope<DefaultCategory>(key,
255  std::forward<Args>(args)...);
256  }
257 
258  /// Record an end event described by \a key if \p Category is enabled.
259  /// It is more efficient to use the \c Scope method than to call both
260  /// \c BeginScope and \c EndScope.
261  /// \sa BeginScope \sa Scope
262  template <typename Category = DefaultCategory>
263  void EndScope(const TraceKey& key) {
264  if (ARCH_LIKELY(!Category::IsEnabled()))
265  return;
266 
267  _EndScope(key, Category::GetId());
268  }
269 
270  /// Record a scope event described by \a key that started at \a start for
271  /// the DefaultCategory.
272  ///
273  /// This method is used by the TRACE_FUNCTION, TRACE_SCOPE and
274  /// TRACE_FUNCTION_SCOPE macros.
275  /// \sa BeginScope \sa EndScope
276  TRACE_API
277  static void
278  Scope(const TraceKey& key, TimeStamp start, TimeStamp stop) noexcept;
279 
280  /// Record a scope event described by \a key that started at \a start if
281  /// \p Category is enabled.
282  ///
283  /// This method is used by the TRACE_FUNCTION, TRACE_SCOPE and
284  /// TRACE_FUNCTION_SCOPE macros.
285  /// \sa BeginScope \sa EndScope
286  template <typename Category = DefaultCategory>
287  void Scope(const TraceKey& key, TimeStamp start, TimeStamp stop) {
288  if (ARCH_LIKELY(!Category::IsEnabled()))
289  return;
290  _PerThreadData *threadData = _GetThreadData();
291  threadData->EmplaceEvent(
292  TraceEvent::Timespan, key, start, stop, Category::GetId());
293  }
294 
295  /// Record multiple data events with category \a cat if \p Category is
296  /// enabled.
297  /// \sa StoreData
298  template <typename Category, typename... Args>
299  void ScopeArgs(Args&&... args) {
300  static_assert( sizeof...(Args) %2 == 0,
301  "Data arguments must come in pairs");
302 
303  if (ARCH_LIKELY(!Category::IsEnabled()))
304  return;
305 
306  _PerThreadData *threadData = _GetThreadData();
307  _StoreDataRec(threadData, Category::GetId(), std::forward<Args>(args)...);
308  }
309 
310  /// Record multiple data events with the default category if collection of
311  /// events is enabled.
312  /// The variadic arguments \a args must be an even number of parameters in
313  /// the form TraceKey, Value. It is more efficient to use this method to
314  /// store multiple data items than to use multiple calls to \c StoreData.
315  /// \sa StoreData
316  template <typename... Args>
317  void ScopeArgs(Args&&... args) {
318  static_assert( sizeof...(Args) %2 == 0,
319  "Data arguments must come in pairs");
320 
321  ScopeArgs<DefaultCategory>(std::forward<Args>(args)...);
322  }
323 
324 
325  /// Record a scope event described by \a key that started at \a start if
326  /// \p Category is enabled.
327  ///
328  /// This method is used by the TRACE_FUNCTION, TRACE_SCOPE and
329  /// TRACE_FUNCTION_SCOPE macros.
330  /// \sa BeginScope \sa EndScope
331  template <typename Category = DefaultCategory>
332  void MarkerEventStatic(const TraceKey& key) {
333  if (ARCH_LIKELY(!Category::IsEnabled()))
334  return;
335 
336  _PerThreadData *threadData = _GetThreadData();
337  threadData->EmplaceEvent(
338  TraceEvent::Marker, key, Category::GetId());
339  }
340 
341  /// Record a data event with the given \a key and \a value if \p Category is
342  /// enabled. \a value may be of any type which a TraceEvent can
343  /// be constructed from (bool, int, std::string, uint64, double).
344  /// \sa ScopeArgs
345  template <typename Category = DefaultCategory, typename T>
346  void StoreData(const TraceKey &key, const T& value) {
347  if (ARCH_UNLIKELY(Category::IsEnabled())) {
348  _StoreData(_GetThreadData(), key, Category::GetId(), value);
349  }
350  }
351 
352  /// Record a counter \a delta for a name \a key if \p Category is enabled.
353  template <typename Category = DefaultCategory>
354  void RecordCounterDelta(const TraceKey &key,
355  double delta) {
356  // Only record counter values if the collector is enabled.
357  if (ARCH_UNLIKELY(Category::IsEnabled())) {
358  _PerThreadData *threadData = _GetThreadData();
359  threadData->EmplaceEvent(
360  TraceEvent::CounterDelta, key, delta, Category::GetId());
361  }
362  }
363 
364  /// Record a counter \a delta for a name \a key if \p Category is enabled.
365  template <typename Category = DefaultCategory>
366  void RecordCounterDelta(const Key &key, double delta) {
367  if (ARCH_UNLIKELY(Category::IsEnabled())) {
368  _PerThreadData *threadData = _GetThreadData();
369  threadData->CounterDelta(key, delta, Category::GetId());
370  }
371  }
372 
373  /// Record a counter \a value for a name \a key if \p Category is enabled.
374  template <typename Category = DefaultCategory>
375  void RecordCounterValue(const TraceKey &key, double value) {
376  // Only record counter values if the collector is enabled.
377  if (ARCH_UNLIKELY(Category::IsEnabled())) {
378  _PerThreadData *threadData = _GetThreadData();
379  threadData->EmplaceEvent(
380  TraceEvent::CounterValue, key, value, Category::GetId());
381  }
382  }
383 
384  /// Record a counter \a value for a name \a key and delta \a value if
385  /// \p Category is enabled.
386  template <typename Category = DefaultCategory>
387  void RecordCounterValue(const Key &key, double value) {
388 
389  if (ARCH_UNLIKELY(Category::IsEnabled())) {
390  _PerThreadData *threadData = _GetThreadData();
391  threadData->CounterValue(key, value, Category::GetId());
392  }
393  }
394 
395  /// @}
396 
397  /// Return the label associated with this collector.
399  return _label;
400  }
401 
402  /// Produces a TraceCollection from all the events that recorded in the
403  /// collector and issues a TraceCollectionAvailable notice. Note that
404  /// creating a collection restarts tracing, i.e. events contained in this
405  /// collection will not be present in subsequent collections.
407 
408 private:
409 
410  TraceCollector();
411 
413 
414  class _PerThreadData;
415 
416  // Return a pointer to existing per-thread data or create one if none
417  // exists.
418  TRACE_API _PerThreadData* _GetThreadData() noexcept;
419 
420  TRACE_API TimeStamp _BeginEvent(const Key& key, TraceCategoryId cat);
421 
422  TRACE_API void _BeginEventAtTime(
423  const Key& key, double ms, TraceCategoryId cat);
424 
425  TRACE_API TimeStamp _EndEvent(const Key& key, TraceCategoryId cat);
426 
427  TRACE_API void _EndEventAtTime(
428  const Key& key, double ms, TraceCategoryId cat);
429 
430  TRACE_API TimeStamp _MarkerEvent(const Key& key, TraceCategoryId cat);
431 
432  TRACE_API void _MarkerEventAtTime(
433  const Key& key, double ms, TraceCategoryId cat);
434 
435  // This is the fast execution path called from the TRACE_FUNCTION
436  // and TRACE_SCOPE macros
437  void _BeginScope(const TraceKey& key, TraceCategoryId cat)
438  {
439  // Note we're not calling _NewEvent, don't need to cache key
440  _PerThreadData *threadData = _GetThreadData();
441  threadData->BeginScope(key, cat);
442  }
443 
444  // This is the fast execution path called from the TRACE_FUNCTION
445  // and TRACE_SCOPE macros
446  TRACE_API void _EndScope(const TraceKey& key, TraceCategoryId cat);
447 
448  TRACE_API void _MeasureScopeOverhead();
449 
450 #ifdef PXR_PYTHON_SUPPORT_ENABLED
451  // Callback function registered as a python tracing function.
452  void _PyTracingCallback(const TfPyTraceInfo &info);
453 #endif // PXR_PYTHON_SUPPORT_ENABLED
454 
455  // Implementation for small data that can stored inlined with the event.
456  template <typename T,
457  typename std::enable_if<
458  sizeof(T) <= sizeof(uintptr_t)
459  && !std::is_pointer<T>::value , int>::type = 0>
460  void _StoreData(_PerThreadData* threadData, const TraceKey &key,
461  TraceCategoryId cat, const T& value) {
462  threadData->StoreData(key, value, cat);
463  }
464 
465  // Implementation for data that must be stored outside of the events.
466  template <typename T,
467  typename std::enable_if<
468  (sizeof(T) > sizeof(uintptr_t))
469  && !std::is_pointer<T>::value, int>::type = 0>
470  void _StoreData(_PerThreadData* threadData, const TraceKey &key,
471  TraceCategoryId cat, const T& value) {
472  threadData->StoreLargeData(key, value, cat);
473  }
474 
475  // Specialization for c string
476  void _StoreData(
477  _PerThreadData* threadData,
478  const TraceKey &key,
479  TraceCategoryId cat,
480  const char* value) {
481  threadData->StoreLargeData(key, value, cat);
482  }
483 
484  // Specialization for std::string
485  void _StoreData(
486  _PerThreadData* threadData,
487  const TraceKey &key,
488  TraceCategoryId cat,
489  const std::string& value) {
490  threadData->StoreLargeData(key, value.c_str(), cat);
491  }
492 
493  // Variadic version to store multiple data events in one function call.
494  template <typename K, typename T, typename... Args>
495  void _StoreDataRec(
496  _PerThreadData* threadData, TraceCategoryId cat, K&& key,
497  const T& value, Args&&... args) {
498  _StoreData(threadData, std::forward<K>(key), cat, value);
499  _StoreDataRec(threadData, cat, std::forward<Args>(args)...);
500  }
501 
502  // Base case to terminate template recursion
503  void _StoreDataRec(_PerThreadData* threadData, TraceCategoryId cat) {}
504 
505 
506  // Thread-local storage, accessed via _GetThreadData()
507  //
508  class _PerThreadData {
509  public:
510  using EventList = TraceCollection::EventList;
511 
512  _PerThreadData();
513  ~_PerThreadData();
514 
515  const TraceThreadId& GetThreadId() const {
516  return _threadIndex;
517  }
518  TimeStamp BeginEvent(const Key& key, TraceCategoryId cat);
519  TimeStamp EndEvent(const Key& key, TraceCategoryId cat);
520  TimeStamp MarkerEvent(const Key& key, TraceCategoryId cat);
521 
522  // Debug Methods
523  void BeginEventAtTime(
524  const Key& key, double ms, TraceCategoryId cat);
525  void EndEventAtTime(const Key& key, double ms, TraceCategoryId cat);
526  void MarkerEventAtTime(const Key& key, double ms, TraceCategoryId cat);
527 
528  void BeginScope(const TraceKey& key, TraceCategoryId cat) {
529  AtomicRef lock(_writing);
530  _BeginScope(key, cat);
531  }
532 
533  void EndScope(const TraceKey& key, TraceCategoryId cat) {
534  AtomicRef lock(_writing);
535  _EndScope(key, cat);
536  }
537 
538  TRACE_API void CounterDelta(
539  const Key&, double value, TraceCategoryId cat);
540 
541  TRACE_API void CounterValue(
542  const Key&, double value, TraceCategoryId cat);
543 
544  template <typename T>
545  void StoreData(
546  const TraceKey& key, const T& data, TraceCategoryId cat) {
547  AtomicRef lock(_writing);
548  _events.load(std::memory_order_acquire)->EmplaceBack(
549  TraceEvent::Data, key, data, cat);
550  }
551 
552  template <typename T>
553  void StoreLargeData(
554  const TraceKey& key, const T& data, TraceCategoryId cat) {
555  AtomicRef lock(_writing);
556  EventList* events = _events.load(std::memory_order_acquire);
557  const auto* cached = events->StoreData(data);
558  events->EmplaceBack(TraceEvent::Data, key, cached, cat);
559  }
560 
561  template <typename... Args>
562  void EmplaceEvent(Args&&... args) {
563  AtomicRef lock(_writing);
564  _events.load(std::memory_order_acquire)->EmplaceBack(
565  std::forward<Args>(args)...);
566  }
567 
568 #ifdef PXR_PYTHON_SUPPORT_ENABLED
569  void PushPyScope(const Key& key, bool enabled);
570  void PopPyScope(bool enabled);
571 #endif // PXR_PYTHON_SUPPORT_ENABLED
572 
573  // These methods can be called from threads at the same time as the
574  // other methods.
575  std::unique_ptr<EventList> GetCollectionData();
576  void Clear();
577 
578  private:
579  void _BeginScope(const TraceKey& key, TraceCategoryId cat) {
580  _events.load(std::memory_order_acquire)->EmplaceBack(
581  TraceEvent::Begin, key, cat);
582  }
583 
584  void _EndScope(const TraceKey& key, TraceCategoryId cat);
585 
586  // Flag to let other threads know that the list is being written to.
587  mutable std::atomic<bool> _writing;
588  std::atomic<EventList*> _events;
589 
590  class AtomicRef {
591  public:
592  AtomicRef(std::atomic<bool>& b) : _bool(b) {
593  _bool.store(true, std::memory_order_release);
594  }
595  ~AtomicRef() {
596  _bool.store(false, std::memory_order_release);
597  }
598  private:
599  std::atomic<bool>& _bool;
600  };
601 
602  // An integer that is unique for each thread launched by any
603  // threadDispatcher. Each time a thread is Start-ed it get's
604  // a new id.
605  //
606  TraceThreadId _threadIndex;
607 
608  // When auto-tracing python frames, this stores the stack of scopes.
609  struct PyScope {
610  Key key;
611  };
612  std::vector<PyScope> _pyScopes;
613  };
614 
615  TRACE_API static std::atomic<int> _isEnabled;
616 
617  // A list with one _PerThreadData per thread.
618  TraceConcurrentList<_PerThreadData> _allPerThreadData;
619 
620  std::string _label;
621 
622  TimeStamp _measuredScopeOverhead;
623 
624  // These members are unused if Python support is disabled. However, we
625  // leave them in place and just mark them unused to provide ABI
626  // compatibility between USD builds with and without Python enabled.
627 #ifndef PXR_PYTHON_SUPPORT_ENABLED
630 #endif
631  std::atomic<int> _isPythonTracingEnabled;
632  TfPyTraceFnId _pyTraceFnId;
633 #ifndef PXR_PYTHON_SUPPORT_ENABLED
635 #endif
636 };
637 
639 
641 
642 #endif // PXR_BASE_TRACE_COLLECTOR_H
#define ARCH_LIKELY(x)
Definition: hints.h:46
static TRACE_API TraceCollector & GetInstance()
Returns the singleton instance.
Definition: collector.h:84
TRACE_API ~TraceCollector()
void RecordCounterValue(const TraceKey &key, double value)
Record a counter value for a name key if Category is enabled.
Definition: collector.h:375
static T & GetInstance()
Definition: singleton.h:137
void RecordCounterValue(const Key &key, double value)
Definition: collector.h:387
#define ARCH_PRAGMA_UNUSED_PRIVATE_FIELD
Definition: pragmas.h:202
GLuint start
Definition: glcorearb.h:475
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLsizei const GLfloat * value
Definition: glcorearb.h:824
TF_MALLOC_TAG_NEW("Trace","TraceCollector")
#define ARCH_PRAGMA_POP
Definition: pragmas.h:170
TRACE_API void SetEnabled(bool isEnabled)
Enables or disables collection of events for DefaultCategory.
fallback_uintptr uintptr_t
Definition: format.h:295
unsigned int GetThreadId()
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glcorearb.h:2539
void EndEventAtTime(const Key &key, double ms)
Definition: collector.h:178
TRACE_API void Clear()
TimeStamp MarkerEvent(const Key &key)
Definition: collector.h:191
void ScopeArgs(Args &&...args)
Definition: collector.h:299
void Scope(const TraceKey &key, TimeStamp start, TimeStamp stop)
Definition: collector.h:287
TraceCollectorPtr ThisPtr
Definition: collector.h:77
void MarkerEventStatic(const TraceKey &key)
Definition: collector.h:332
void MarkerEventAtTime(const Key &key, double ms)
Definition: collector.h:204
std::shared_ptr< TfPyTraceFn > TfPyTraceFnId
Definition: pyTracing.h:70
TRACE_API TimeStamp GetScopeOverhead() const
Return the overhead cost to measure a scope.
#define ARCH_UNLIKELY(x)
Definition: hints.h:47
static bool IsEnabled()
Returns whether collection of events is enabled for DefaultCategory.
Definition: collector.h:94
#define ARCH_PRAGMA_PUSH
Definition: pragmas.h:166
void BeginScope(const TraceKey &key, Args &&...args)
Definition: collector.h:248
void EndScope(const TraceKey &key)
Definition: collector.h:263
void ScopeArgs(Args &&...args)
Definition: collector.h:317
void RecordCounterDelta(const Key &key, double delta)
Record a counter delta for a name key if Category is enabled.
Definition: collector.h:366
TraceEventList EventList
Definition: collection.h:55
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
void BeginScope(const TraceKey &key, Args &&...args)
Definition: collector.h:230
TimeStamp EndEvent(const Key &key)
Definition: collector.h:165
TRACE_API void CreateCollection()
static bool IsEnabled()
Returns the result of TraceCollector::IsEnabled.
Definition: collector.h:104
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
TraceDynamicKey Key
Definition: collector.h:81
void BeginScope(const TraceKey &_key)
Definition: collector.h:217
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
void StoreData(const TraceKey &key, const T &value)
Definition: collector.h:346
TimeStamp BeginEvent(const Key &key)
Definition: collector.h:136
static TRACE_API void Scope(const TraceKey &key, TimeStamp start, TimeStamp stop) noexcept
TF_DECLARE_WEAK_AND_REF_PTRS(TraceScope)
uint64_t TimeStamp
Time in "ticks".
Definition: event.h:50
**If you just want to fire and args
Definition: thread.h:609
TRACE_API_TEMPLATE_CLASS(TfSingleton< TraceCollector >)
Definition: core.h:1131
static constexpr TraceCategoryId GetId()
Returns TraceCategory::Default.
Definition: collector.h:102
TF_DECLARE_WEAK_PTRS(TraceCollector)
void BeginEventAtTime(const Key &key, double ms)
Definition: collector.h:149
uint32_t TraceCategoryId
Categories that a TraceReporter can use to filter events.
Definition: category.h:44
type
Definition: core.h:1059
TraceEvent::TimeStamp TimeStamp
Definition: collector.h:79
void RecordCounterDelta(const TraceKey &key, double delta)
Record a counter delta for a name key if Category is enabled.
Definition: collector.h:354
Definition: format.h:895
const std::string & GetLabel()
Return the label associated with this collector.
Definition: collector.h:398
#define TRACE_API
Definition: api.h:40
Definition: key.h:40