Ion
|
Class for recording frame events. More...
#include "tracerecorder.h"
Classes | |
struct | TraceHeader |
Public Types | |
typedef base::CircularBuffer < uint32 > | TraceBuffer |
typedef std::unordered_map < uint32, std::string > | IndexToStringMap |
Public Member Functions | |
TraceRecorder (CallTraceManager *manager) | |
TraceRecorder (CallTraceManager *manager, size_t buffer_size) | |
Explicitly specify the capacity of this recorder in bytes. More... | |
void | EnterScope (int event_id) |
Queries and records the event corresponding to the provided event_id. More... | |
void | AnnotateCurrentScope (const std::string &name, const std::string &value) |
Attaches data to the current scope, which will be visible on mouse-over. More... | |
void | LeaveScope () |
Leaves the current (most recent) scope. More... | |
void | EnterScopeAtTime (uint32 timestamp, int event_id) |
Same as EnterScope, but with specified timestamp. More... | |
void | AnnotateCurrentScopeAtTime (uint32 timestamp, const std::string &name, const std::string &value) |
Same as AnnotateCurrentScope, but with specified timestamp. More... | |
void | LeaveScopeAtTime (uint32 timestamp) |
Same as LeaveScope, but with specified timestamp. More... | |
void | EnterFrame (uint32 frame_number) |
Records a frame enter event with a specified frame index. More... | |
void | LeaveFrame () |
Records a frame exit event for the current frame index. More... | |
void | EnterTimeRange (uint32 unique_id, const char *name, const char *value) |
Records the start of a time range event. More... | |
uint32 | EnterTimeRange (const char *name, const char *value) |
Records the start of a time range event. More... | |
void | LeaveTimeRange (uint32 id) |
Records the end of a time range event for the specified unique id. More... | |
void | CreateTimeStamp (const char *name, const char *value) |
Records a timeStamp event. More... | |
void | CreateTimeStampAtTime (uint32 timestamp, const char *name, const char *value) |
Same as CreateTimeStamp, but with specified timestamp. More... | |
size_t | GetNumTraces () const |
Returns the total number of recorded trace events. More... | |
const ion::port::ThreadId & | GetThreadId () const |
Returns the ID of the thread that this recorder is tracing. More... | |
void | SetThreadName (const std::string &name) |
Sets a name for the thread that this recorder is tracing. More... | |
std::string | GetThreadName () const |
Returns the name for the thread that this recorder is tracing. More... | |
void | DumpStrings (std::vector< std::string > *table) const |
Dumps the strings one by one to a string table. More... | |
void | DumpTrace (std::string *output, uint32 string_index_offset) const |
Appends a binary dump of the trace to the output string. More... | |
void | AddTraceToTimelineNode (TimelineNode *root) const |
Adds all events in the trace as a sub-tree under the passed in root node. More... | |
uint32 | GetCurrentFrameNumber () const |
Returns the frame number of the current frame scope, or 0 (and a warning message) if TraceRecorder is not in a frame scope. More... | |
bool | IsInFrameScope () const |
Returns if the TraceRecorder is currently in a frame scope. More... | |
const AllocatorPtr & | GetAllocator () const |
Returns the Allocator that was used for the instance. More... | |
const AllocatorPtr & | GetNonNullAllocator () const |
Return our allocator, or the default allocator if the instance was declared on the stack. More... | |
const AllocatorPtr & | GetAllocatorForLifetime (AllocationLifetime lifetime) const |
Convenience function that returns the Allocator to use to allocate an object with a specific lifetime. More... | |
void * | operator new (size_t size) |
The standard no-parameter new operator uses the default Allocator. More... | |
void * | operator new (size_t size, AllocationLifetime lifetime) |
This overloaded version of the new operator uses the AllocationManager's default Allocator for the specified lifetime. More... | |
void * | operator new (size_t size, const AllocatorPtr &allocator) |
This overloaded version of the new operator takes the Allocator to use directly as a parameter. More... | |
void * | operator new (size_t size, const AllocatorPtr &allocator, void *ptr) |
Special operator new for using placement new with Allocatables. More... | |
void * | operator new (size_t size, void *ptr) |
The placement new operator is defined conventionally. More... | |
void | operator delete (void *ptr) |
Define the delete operator to use specialized functions dealing with an Allocator. More... | |
void | operator delete (void *ptr, AllocationLifetime lifetime) |
Windows requires these (or it issues C4291 warnings). More... | |
void | operator delete (void *ptr, const AllocatorPtr &allocator) |
void | operator delete (void *ptr, void *ptr2) |
The placement delete operator does nothing, as usual. More... | |
Static Public Member Functions | |
static size_t | GetDefaultBufferSize () |
Manipulate the default buffer size in bytes used for future instantiations. More... | |
static void | SetDefaultBufferSize (size_t s) |
static bool | GetReserveBuffer () |
Maniupulate whether or not to reserve the full buffer size immediately for future instantiations. More... | |
static void | SetReserveBuffer (bool reserve) |
Class for recording frame events.
This class tracks events based on pointers to raw string literals. It hashes the pointer value of the literal to a unique frame event id to keep track of events.
Definition at line 42 of file tracerecorder.h.
typedef std::unordered_map<uint32, std::string> ion::profile::TraceRecorder::IndexToStringMap |
Definition at line 52 of file tracerecorder.h.
typedef base::CircularBuffer<uint32> ion::profile::TraceRecorder::TraceBuffer |
Definition at line 51 of file tracerecorder.h.
|
explicit |
Definition at line 61 of file tracerecorder.cc.
References ion::base::CircularBuffer< T >::AddItem().
ion::profile::TraceRecorder::TraceRecorder | ( | CallTraceManager * | manager, |
size_t | buffer_size | ||
) |
Explicitly specify the capacity of this recorder in bytes.
Definition at line 74 of file tracerecorder.cc.
References ion::base::CircularBuffer< T >::AddItem().
void ion::profile::TraceRecorder::AddTraceToTimelineNode | ( | TimelineNode * | root | ) | const |
Adds all events in the trace as a sub-tree under the passed in root node.
Definition at line 346 of file tracerecorder.cc.
References TimelineNode::AddChild(), CHECK, DCHECK, DCHECK_LT, TimelineNode::GetEnd(), ion::base::CircularBuffer< T >::GetItem(), ion::profile::CallTraceManager::GetNumArgsForEvent(), TimelineNode::GetParent(), ion::base::CircularBuffer< T >::GetSize(), ion::profile::CallTraceManager::kCustomScopeEvent, ion::profile::CallTraceManager::kFrameEndEvent, ion::profile::CallTraceManager::kFrameStartEvent, ion::profile::CallTraceManager::kScopeAppendDataEvent, ion::profile::CallTraceManager::kScopeLeaveEvent, ion::profile::CallTraceManager::kTimeRangeEndEvent, and ion::profile::CallTraceManager::kTimeRangeStartEvent.
Referenced by ion::profile::CallTraceManager::BuildTimeline().
void ion::profile::TraceRecorder::AnnotateCurrentScope | ( | const std::string & | name, |
const std::string & | value | ||
) |
Attaches data to the current scope, which will be visible on mouse-over.
The string value
must be in JSON format, e.g. "\"my_string"" for a
string value, "18" for the integer value 18,
"{ "name": "my_name", "count": 17 }" for an object with two key value pairs.
value
must not be a string representation of NaN or infinity, because these values are not supported by JSON. Definition at line 90 of file tracerecorder.cc.
References AnnotateCurrentScopeAtTime(), ion::profile::CallTraceManager::GetTimeInUs(), name, and value.
void ion::profile::TraceRecorder::AnnotateCurrentScopeAtTime | ( | uint32 | timestamp, |
const std::string & | name, | ||
const std::string & | value | ||
) |
Same as AnnotateCurrentScope, but with specified timestamp.
Definition at line 105 of file tracerecorder.cc.
References ion::base::CircularBuffer< T >::AddItem(), DCHECK, DCHECK_NE, ion::profile::CallTraceManager::kScopeAppendDataEvent, ion::base::TrimEndWhitespace(), and ion::base::ValueToString().
Referenced by AnnotateCurrentScope().
void ion::profile::TraceRecorder::CreateTimeStamp | ( | const char * | name, |
const char * | value | ||
) |
Records a timeStamp event.
Definition at line 204 of file tracerecorder.cc.
References CreateTimeStampAtTime(), ion::profile::CallTraceManager::GetTimeInUs(), name, and value.
void ion::profile::TraceRecorder::CreateTimeStampAtTime | ( | uint32 | timestamp, |
const char * | name, | ||
const char * | value | ||
) |
Same as CreateTimeStamp, but with specified timestamp.
Definition at line 208 of file tracerecorder.cc.
References ion::base::CircularBuffer< T >::AddItem(), DCHECK, ion::profile::CallTraceManager::kTimeStampEvent, and ion::base::TrimEndWhitespace().
Referenced by CreateTimeStamp(), and ion::profile::VSyncProfiler::RecordVSyncEvent().
void ion::profile::TraceRecorder::DumpStrings | ( | std::vector< std::string > * | table | ) | const |
Dumps the strings one by one to a string table.
Definition at line 254 of file tracerecorder.cc.
References DCHECK_LT.
Referenced by ion::profile::CallTraceManager::SnapshotCallTraces().
void ion::profile::TraceRecorder::DumpTrace | ( | std::string * | output, |
uint32 | string_index_offset | ||
) | const |
Appends a binary dump of the trace to the output string.
Definition at line 263 of file tracerecorder.cc.
References ion::base::AppendBytes(), DCHECK, ion::profile::CallTraceManager::GetArgType(), ion::base::CircularBuffer< T >::GetItem(), ion::profile::CallTraceManager::GetNumArgsForEvent(), ion::base::CircularBuffer< T >::GetSize(), ion::profile::CallTraceManager::kArgNone, and ion::profile::CallTraceManager::kArgString.
Referenced by ion::profile::CallTraceManager::SnapshotCallTraces().
void ion::profile::TraceRecorder::EnterFrame | ( | uint32 | frame_number | ) |
Records a frame enter event with a specified frame index.
Definition at line 134 of file tracerecorder.cc.
References ion::base::CircularBuffer< T >::AddItem(), ion::profile::CallTraceManager::GetTimeInUs(), and ion::profile::CallTraceManager::kFrameStartEvent.
Referenced by ion::profile::ScopedFrameTracer::ScopedFrameTracer().
void ion::profile::TraceRecorder::EnterScope | ( | int | event_id | ) |
Queries and records the event corresponding to the provided event_id.
Definition at line 86 of file tracerecorder.cc.
References EnterScopeAtTime(), and ion::profile::CallTraceManager::GetTimeInUs().
Referenced by ion::profile::ScopedTracer::ScopedTracer().
void ion::profile::TraceRecorder::EnterScopeAtTime | ( | uint32 | timestamp, |
int | event_id | ||
) |
Same as EnterScope, but with specified timestamp.
Definition at line 99 of file tracerecorder.cc.
References ion::base::CircularBuffer< T >::AddItem().
Referenced by EnterScope(), and ion::gfxprofile::GpuProfiler::PollGlTimerQueries().
void ion::profile::TraceRecorder::EnterTimeRange | ( | uint32 | unique_id, |
const char * | name, | ||
const char * | value | ||
) |
Records the start of a time range event.
The event is uniquely specified by some 32-bit integer id, with a given name and optional string value in JSON format. The name must be given, but the value is optional and can be NULL.
Definition at line 160 of file tracerecorder.cc.
References ion::base::CircularBuffer< T >::AddItem(), DCHECK, ion::profile::CallTraceManager::GetTimeInUs(), ion::profile::CallTraceManager::kTimeRangeStartEvent, and ion::base::TrimEndWhitespace().
uint32 ion::profile::TraceRecorder::EnterTimeRange | ( | const char * | name, |
const char * | value | ||
) |
Records the start of a time range event.
This method will automatically assign and return a unique uint32 "id" used to identify the time range event. Note the name must be given; however the parameter string value
(JSON format) is an optional value and can be NULL.
Definition at line 177 of file tracerecorder.cc.
References ion::base::CircularBuffer< T >::AddItem(), DCHECK, ion::profile::CallTraceManager::GetTimeInUs(), ion::profile::CallTraceManager::kTimeRangeStartEvent, and ion::base::TrimEndWhitespace().
|
inlineinherited |
Returns the Allocator that was used for the instance.
This will be NULL if the instance was declared on the stack or created with normal placement new.
Definition at line 68 of file allocatable.h.
References allocator_.
Referenced by ion::base::DataContainer::CreateAndCopy(), ion::text::DynamicFontImage::FindContainingImageDataIndex(), and ion::text::DynamicFontImage::FindImageDataIndex().
|
inlineinherited |
Convenience function that returns the Allocator to use to allocate an object with a specific lifetime.
Definition at line 78 of file allocatable.h.
References ion::base::Allocator::GetAllocatorForLifetime().
Referenced by ion::text::BasicBuilder::BuildVertexData(), ion::text::OutlineBuilder::BuildVertexData(), ion::gfxutils::ShaderManager::CreateShaderProgram(), ion::text::DynamicFontImage::FindContainingImageDataIndex(), ion::text::DynamicFontImage::FindImageDataIndex(), ion::gfx::Renderer::Renderer(), and ion::gfx::UpdateStateTable().
uint32 ion::profile::TraceRecorder::GetCurrentFrameNumber | ( | ) | const |
Returns the frame number of the current frame scope, or 0 (and a warning message) if TraceRecorder is not in a frame scope.
Definition at line 427 of file tracerecorder.cc.
References IsInFrameScope(), LOG_ONCE, and ion::port::WARNING.
|
inlinestatic |
Manipulate the default buffer size in bytes used for future instantiations.
Definition at line 60 of file tracerecorder.h.
|
inlineinherited |
Return our allocator, or the default allocator if the instance was declared on the stack.
Definition at line 72 of file allocatable.h.
References allocator_, and ion::base::AllocationManager::GetNonNullAllocator().
size_t ion::profile::TraceRecorder::GetNumTraces | ( | ) | const |
Returns the total number of recorded trace events.
Definition at line 224 of file tracerecorder.cc.
References ion::base::CircularBuffer< T >::GetItem(), ion::profile::CallTraceManager::GetNumArgsForEvent(), ion::base::CircularBuffer< T >::GetSize(), and length.
|
inlinestatic |
Maniupulate whether or not to reserve the full buffer size immediately for future instantiations.
Definition at line 65 of file tracerecorder.h.
|
inline |
Returns the ID of the thread that this recorder is tracing.
Definition at line 128 of file tracerecorder.h.
Referenced by ion::profile::CallTraceManager::BuildTimeline().
|
inline |
Returns the name for the thread that this recorder is tracing.
The name is "UnnamedThread" unless it has been set by a call to SetThreadName.
Definition at line 135 of file tracerecorder.h.
Referenced by ion::profile::CallTraceManager::BuildTimeline().
|
inline |
Returns if the TraceRecorder is currently in a frame scope.
Definition at line 151 of file tracerecorder.h.
Referenced by GetCurrentFrameNumber(), and LeaveFrame().
void ion::profile::TraceRecorder::LeaveFrame | ( | ) |
Records a frame exit event for the current frame index.
Definition at line 145 of file tracerecorder.cc.
References ion::base::CircularBuffer< T >::AddItem(), ion::profile::CallTraceManager::GetTimeInUs(), IsInFrameScope(), ion::profile::CallTraceManager::kFrameEndEvent, LOG_ONCE, and ion::port::WARNING.
Referenced by ion::profile::ScopedFrameTracer::~ScopedFrameTracer().
void ion::profile::TraceRecorder::LeaveScope | ( | ) |
Leaves the current (most recent) scope.
Scope events must be strictly nested.
Definition at line 95 of file tracerecorder.cc.
References ion::profile::CallTraceManager::GetTimeInUs(), and LeaveScopeAtTime().
Referenced by ion::profile::ScopedTracer::~ScopedTracer().
void ion::profile::TraceRecorder::LeaveScopeAtTime | ( | uint32 | timestamp | ) |
Same as LeaveScope, but with specified timestamp.
Definition at line 124 of file tracerecorder.cc.
References ion::base::CircularBuffer< T >::AddItem(), DCHECK_GT, and ion::profile::CallTraceManager::kScopeLeaveEvent.
Referenced by LeaveScope(), and ion::gfxprofile::GpuProfiler::PollGlTimerQueries().
void ion::profile::TraceRecorder::LeaveTimeRange | ( | uint32 | id | ) |
Records the end of a time range event for the specified unique id.
Definition at line 198 of file tracerecorder.cc.
References ion::base::CircularBuffer< T >::AddItem(), ion::profile::CallTraceManager::GetTimeInUs(), and ion::profile::CallTraceManager::kTimeRangeEndEvent.
|
inlineinherited |
Define the delete operator to use specialized functions dealing with an Allocator.
Definition at line 109 of file allocatable.h.
|
inlineinherited |
Windows requires these (or it issues C4291 warnings).
Definition at line 112 of file allocatable.h.
|
inlineinherited |
Definition at line 113 of file allocatable.h.
|
inlineinherited |
The placement delete operator does nothing, as usual.
Definition at line 118 of file allocatable.h.
|
inlineinherited |
The standard no-parameter new operator uses the default Allocator.
Definition at line 84 of file allocatable.h.
|
inlineinherited |
This overloaded version of the new operator uses the AllocationManager's default Allocator for the specified lifetime.
Definition at line 88 of file allocatable.h.
|
inlineinherited |
This overloaded version of the new operator takes the Allocator to use directly as a parameter.
If the Allocator pointer is NULL, this uses the default Allocator.
Definition at line 95 of file allocatable.h.
|
inlineinherited |
Special operator new for using placement new with Allocatables.
Definition at line 100 of file allocatable.h.
|
inlineinherited |
The placement new operator is defined conventionally.
Definition at line 105 of file allocatable.h.
|
inlinestatic |
Definition at line 61 of file tracerecorder.h.
|
inlinestatic |
Definition at line 66 of file tracerecorder.h.
|
inline |
Sets a name for the thread that this recorder is tracing.
Definition at line 131 of file tracerecorder.h.
References name.
Referenced by ion::profile::CallTraceManager::GetNamedTraceRecorder().