8#ifndef PXR_BASE_TRACE_EVENT_H
9#define PXR_BASE_TRACE_EVENT_H
13#include "pxr/base/trace/api.h"
15#include "pxr/base/trace/key.h"
19PXR_NAMESPACE_OPEN_SCOPE
38 enum BeginTag { Begin };
40 enum TimespanTag { Timespan };
41 enum MarkerTag { Marker };
42 enum CounterDeltaTag { CounterDelta };
43 enum CounterValueTag { CounterValue };
44 enum DataTag { Data };
102 _type(_InternalEventType::Begin),
113 _type(_InternalEventType::Begin),
122 _type(_InternalEventType::End),
133 _type(_InternalEventType::End),
139 TimespanTag,
const Key& key,
144 _type(_InternalEventType::Timespan),
154 _type(_InternalEventType::Marker),
165 _type(_InternalEventType::Marker),
176 _type(_InternalEventType::CounterDelta),
178 new (&_payload)
double(value);
188 _type(_InternalEventType::CounterValue),
190 new (&_payload)
double(value);
201 new (&_payload)
bool(data);
210 new (&_payload) int64_t(data);
219 new (&_payload) int64_t(data);
228 new (&_payload) uint64_t(data);
237 new (&_payload)
double(data);
244 _type(_InternalEventType::ScopeDataLarge),
246 new (&_payload)
const char*(data);
264 enum class _InternalEventType : uint8_t {
275 using PayloadStorage = std::aligned_storage<8, 8>::type;
280 _InternalEventType _type;
282 PayloadStorage _payload;
285PXR_NAMESPACE_CLOSE_SCOPE
uint32_t TraceCategoryId
Categories that a TraceReporter can use to filter events.
This class holds data that can be stored in TraceEvents.
This represents an event recorded by a TraceCollector.
TRACE_API TraceEventData GetData() const
Returns the data stored in a data event.
uint64_t TimeStamp
Time in "ticks".
TraceEvent(MarkerTag, const Key &key, TraceCategoryId cat)
Constructor for Marker events that will automatically set the timestamp from the current time.
TRACE_API double GetCounterValue() const
Return the counter value associated with this event.
TraceEvent(MarkerTag, const Key &key, TimeStamp ts, TraceCategoryId cat)
Constructor for Mark events that takes a specific TimeStamp ts.
const Key & GetKey() const
Return this event's key.
TraceEvent(EndTag, const Key &key, TimeStamp ts, TraceCategoryId cat)
Constructor for End events that takes a specific TimeStamp ts.
DataType
The different types of data that can be stored in a TraceEvent instance.
@ UInt
The event is storing an unsigned integer.
@ Int
The event is storing an integer.
@ Float
The event is storing an double.
@ String
The event is storing a string.
@ Boolean
The event is storing a bool.
@ Invalid
The event is not storing any data.
TraceEvent(BeginTag, const Key &key, TraceCategoryId cat)
Constructor for Begin events that will automatically set the timestamp from the current time.
TraceEvent(TimespanTag, const Key &key, TimeStamp startTime, TimeStamp endTime, TraceCategoryId cat)
Constructor for Timespan events that takes the start time and end time.
TRACE_API EventType GetType() const
Returns the type of the event.
TraceEvent(CounterValueTag, const Key &key, double value, TraceCategoryId cat)
Constructor for Counter value events.
TraceEvent(BeginTag, const Key &key, TimeStamp ts, TraceCategoryId cat)
Constructor for Begin events that takes a specific TimeStamp ts.
TraceCategoryId GetCategory() const
Returns the event's category id.
TraceEvent(CounterDeltaTag, const Key &key, double value, TraceCategoryId cat)
Constructor for Counter delta events.
TRACE_API TimeStamp GetEndTimeStamp() const
Returns the end time of a timespan event.
TraceEvent(EndTag, const Key &key, TraceCategoryId cat)
Constructor for End events that will automatically set the timestamp from the current time.
TRACE_API TimeStamp GetTimeStamp() const
Return the time stamp associated with this event.
void SetTimeStamp(TimeStamp time)
Sets the events timestamp to time.
TRACE_API TimeStamp GetStartTimeStamp() const
Returns the start time of a timespan event.
EventType
Valid event types.
@ ScopeData
The event stores data that is associated with its enclosing scope.
@ Unknown
The event is an unknown type.
A wrapper around a TraceStaticKeyData pointer that is stored in TraceEvent instances.
uint64_t ArchGetTickTime()
Return the current time in system-dependent units.
High-resolution, low-cost timing routines.