Ion
|
Manages call trace recording for visualization in Web Tracing Framework (WTF) format. More...
#include "calltracemanager.h"
Public Types | |
enum | EventArgType { kArgNone, kArgNumeric, kArgString } |
Defines argument types for WTF events. More... | |
enum | BuiltinEventType { kDefineEvent = 1, kCreateZoneEvent = 3, kDeleteZoneEvent = 4, kSetZoneEvent = 5, kScopeLeaveEvent = 8, kScopeAppendDataEvent = 9, kMarkEvent = 10, kTimeStampEvent = 11, kTimeRangeStartEvent = 12, kTimeRangeEndEvent = 13, kFrameStartEvent = 14, kFrameEndEvent = 15, kCustomScopeEvent = 100 } |
Defines the built-in WTF events that we use. More... | |
enum | NamedTraceRecorderType { kRecorderGpu = 0, kRecorderVSync, kNumNamedTraceRecorders } |
Defines name trace recorders. More... | |
typedef base::AllocUnorderedMap< const void *, uint32 > | ScopeEventMap |
Custom scope event mapping from name (as a pointer to a literal string) to uint32 id. More... | |
typedef base::AllocUnorderedMap < uint32, const char * > | ReverseScopeEventMap |
Reversed mapping from custom scope event id to name. More... | |
typedef base::AllocVector < TraceRecorder * > | TraceList |
List of TraceRecorders, one created for each thread of execution. More... | |
Public Member Functions | |
CallTraceManager () | |
CallTraceManager (size_t buffer_size) | |
Construct using the specified trace capacity in bytes. More... | |
~CallTraceManager () override | |
TraceRecorder * | GetTraceRecorder () |
Gets the TraceRecorder instance specific to the current thread. More... | |
TraceRecorder * | GetNamedTraceRecorder (NamedTraceRecorderType name) |
Gets the TraceRecorder instance specific to the current thread of the given name. More... | |
const TraceList & | GetAllTraceRecorders () const |
Gets the list of all trace recorders for all threads. More... | |
int | GetScopeEnterEvent (const char *string_id) |
Queries the event id of a scope enter event, based on string_id. More... | |
const char * | GetScopeEnterEventName (uint32 event_id) const |
Returns the name of the scope enter event with the given id. More... | |
size_t | GetNumScopeEvents () const |
Returns the number of unique custom scope events recorded. More... | |
std::string | SnapshotCallTraces () const |
Returns a snapshot of traces to a string in binary .wtf-trace format. More... | |
virtual uint32 | GetTimeInUs () const |
Returns the time in microseconds, relative to the timebase. More... | |
uint64 | GetTimeInNs () const |
Returns the time in nanoseconds, relative to the timebase. More... | |
void | WriteFile (const std::string &filename) const |
Writes the current WTF trace to a file, which usually ends in the extension ".wtf-trace". More... | |
Timeline | BuildTimeline () const |
Convert the current WTF trace into a timeline. More... | |
void | RegisterTimelineMetric (std::unique_ptr< TimelineMetric > metric) |
Registers a timeline metric. More... | |
analytics::Benchmark | RunTimelineMetrics () const |
Runs all registered metrics on the current timeline and returns a benchmark object containing the collected statistics. 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 int | GetNumArgsForEvent (uint32 event_id) |
Gets the number of arguments for a particular event. More... | |
static EventArgType | GetArgType (uint32 event_id, int arg_index) |
Gets the argument types for a particular event. More... | |
Manages call trace recording for visualization in Web Tracing Framework (WTF) format.
This class maintains a separate recording buffer for each thread.
Definition at line 44 of file calltracemanager.h.
typedef base::AllocUnorderedMap<uint32, const char*> ion::profile::CallTraceManager::ReverseScopeEventMap |
Reversed mapping from custom scope event id to name.
Definition at line 102 of file calltracemanager.h.
typedef base::AllocUnorderedMap<const void*, uint32> ion::profile::CallTraceManager::ScopeEventMap |
Custom scope event mapping from name (as a pointer to a literal string) to uint32 id.
Note we explicitly cast the pointer to const void* since we do want to hash the pointer instead of the string; std::hash<const char*> would return error here.
Definition at line 99 of file calltracemanager.h.
List of TraceRecorders, one created for each thread of execution.
Definition at line 105 of file calltracemanager.h.
Defines the built-in WTF events that we use.
Definition at line 54 of file calltracemanager.h.
Defines argument types for WTF events.
Enumerator | |
---|---|
kArgNone | |
kArgNumeric | |
kArgString |
Definition at line 47 of file calltracemanager.h.
Defines name trace recorders.
Enumerator | |
---|---|
kRecorderGpu | |
kRecorderVSync | |
kNumNamedTraceRecorders |
Definition at line 89 of file calltracemanager.h.
ion::profile::CallTraceManager::CallTraceManager | ( | ) |
Definition at line 238 of file calltracemanager.cc.
|
explicit |
Construct using the specified trace capacity in bytes.
Definition at line 247 of file calltracemanager.cc.
|
override |
Definition at line 256 of file calltracemanager.cc.
References ion::analytics::OutputBenchmarkPretty(), and RunTimelineMetrics().
Timeline ion::profile::CallTraceManager::BuildTimeline | ( | ) | const |
Convert the current WTF trace into a timeline.
Definition at line 634 of file calltracemanager.cc.
References TimelineNode::AddChild(), ion::profile::TraceRecorder::AddTraceToTimelineNode(), ion::profile::TraceRecorder::GetThreadId(), and ion::profile::TraceRecorder::GetThreadName().
Referenced by RunTimelineMetrics().
|
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().
|
inline |
Gets the list of all trace recorders for all threads.
Definition at line 123 of file calltracemanager.h.
|
static |
Gets the argument types for a particular event.
Definition at line 351 of file calltracemanager.cc.
References CHECK, kArgNone, kArgNumeric, kArgString, and kCustomScopeEvent.
Referenced by ion::profile::TraceRecorder::DumpTrace().
TraceRecorder * ion::profile::CallTraceManager::GetNamedTraceRecorder | ( | NamedTraceRecorderType | name | ) |
Gets the TraceRecorder instance specific to the current thread of the given name.
These are used for non-CPU-thread tracing such as for GPU events.
Definition at line 282 of file calltracemanager.cc.
References DCHECK, ion::base::ThreadLocalObject< T >::Get(), kNumNamedTraceRecorders, kRecorderGpu, kRecorderVSync, LOG, name, ion::profile::TraceRecorder::SetThreadName(), and ion::port::WARNING.
Referenced by ion::gfxprofile::GpuProfiler::PollGlTimerQueries().
|
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().
|
static |
Gets the number of arguments for a particular event.
Definition at line 339 of file calltracemanager.cc.
References kCustomScopeEvent.
Referenced by ion::profile::TraceRecorder::AddTraceToTimelineNode(), ion::profile::TraceRecorder::DumpTrace(), and ion::profile::TraceRecorder::GetNumTraces().
|
inline |
Returns the number of unique custom scope events recorded.
Definition at line 139 of file calltracemanager.h.
Referenced by GetScopeEnterEvent().
int ion::profile::CallTraceManager::GetScopeEnterEvent | ( | const char * | string_id | ) |
Queries the event id of a scope enter event, based on string_id.
Only raw string literals are allowed for the string_id argument.
Definition at line 319 of file calltracemanager.cc.
References GetNumScopeEvents(), and kCustomScopeEvent.
const char * ion::profile::CallTraceManager::GetScopeEnterEventName | ( | uint32 | event_id | ) | const |
Returns the name of the scope enter event with the given id.
Definition at line 335 of file calltracemanager.cc.
|
inline |
Returns the time in nanoseconds, relative to the timebase.
The timebase is the time when this CallTraceManager instance was created, expressed in nanoseconds since the epoch.
Definition at line 157 of file calltracemanager.h.
References ion::port::Timer::Get().
Referenced by ion::gfxprofile::GpuProfiler::EnterGlScope(), ion::gfxprofile::GpuProfiler::LeaveGlScope(), and ion::gfxprofile::GpuProfiler::PollGlTimerQueries().
|
inlinevirtual |
Returns the time in microseconds, relative to the timebase.
The timebase is the time when this CallTraceManager instance was created, expressed in microseconds since the epoch.
Definition at line 148 of file calltracemanager.h.
References ion::port::Timer::Get().
Referenced by ion::profile::TraceRecorder::AnnotateCurrentScope(), ion::profile::TraceRecorder::CreateTimeStamp(), ion::profile::TraceRecorder::EnterFrame(), ion::profile::TraceRecorder::EnterScope(), ion::profile::TraceRecorder::EnterTimeRange(), ion::profile::TraceRecorder::LeaveFrame(), ion::profile::TraceRecorder::LeaveScope(), and ion::profile::TraceRecorder::LeaveTimeRange().
TraceRecorder * ion::profile::CallTraceManager::GetTraceRecorder | ( | ) |
Gets the TraceRecorder instance specific to the current thread.
Definition at line 271 of file calltracemanager.cc.
References ion::port::GetThreadLocalStorage().
|
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.
|
inline |
Registers a timeline metric.
Definition at line 171 of file calltracemanager.h.
analytics::Benchmark ion::profile::CallTraceManager::RunTimelineMetrics | ( | ) | const |
Runs all registered metrics on the current timeline and returns a benchmark object containing the collected statistics.
Definition at line 646 of file calltracemanager.cc.
References BuildTimeline().
Referenced by ~CallTraceManager().
std::string ion::profile::CallTraceManager::SnapshotCallTraces | ( | ) | const |
Returns a snapshot of traces to a string in binary .wtf-trace format.
https://github.com/google/tracing-framework/blob/master/docs/wtf-trace.md
Definition at line 386 of file calltracemanager.cc.
References ion::base::AppendBytes(), ion::profile::TraceRecorder::DumpStrings(), ion::profile::TraceRecorder::DumpTrace(), kCreateZoneEvent, kDefineEvent, kSetZoneEvent, table, and ion::base::ValueToString().
Referenced by ion::remote::CallTraceHandler::HandleRequest(), and WriteFile().
void ion::profile::CallTraceManager::WriteFile | ( | const std::string & | filename | ) | const |
Writes the current WTF trace to a file, which usually ends in the extension ".wtf-trace".
Definition at line 619 of file calltracemanager.cc.
References ion::port::INFO, LOG, SnapshotCallTraces(), and ion::port::WARNING.