Support Forum       G3D Web Page     
Classes | Static Public Member Functions | List of all members
G3D::Profiler Class Reference

Measures execution time of CPU and GPU events across multiple threads. More...

Classes

class  Event
 May have child Events. More...
 

Static Public Member Functions

static void beginEvent (const String &name, const String &file, int line, const String &hint="")
 Calls to beginEvent may be nested on a single thread. More...
 
static bool enabled ()
 When disabled no profiling occurs (i.e., beginCPU and beginGFX do nothing). More...
 
static void endEvent ()
 Ends the most recent pending event on the current thread. More...
 
static void getEvents (Array< const Array< Event > *> &eventTrees)
 Return all events from the previous frame, one array per thread. More...
 
static void getEventTime (const String &eventName, RealTime &cpuTime, RealTime &gfxTime)
 Returns the sum of all time spent in events with this name (which may be zero, if they do not exist) across all threads. More...
 
static bool LAUNCH_SHADER_timingEnabled ()
 Whether to make profile events in every LAUNCH_SHADER call. More...
 
static void nextFrame ()
 Notify the profiler to latch the current event tree. More...
 
static void set_LAUNCH_SHADER_timingEnabled (bool enabled)
 Set whether to make profile events in every LAUNCH_SHADER call. More...
 
static void setEnabled (bool e)
 When disabled no profiling occurs (i.e., beginCPU and beginGFX do nothing).
More...
 
static void threadShutdownHook ()
 Do not call directly if using Thread. More...
 

Detailed Description

Measures execution time of CPU and GPU events across multiple threads.

Member Function Documentation

◆ beginEvent()

static void G3D::Profiler::beginEvent ( const String name,
const String file,
int  line,
const String hint = "" 
)
static

Calls to beginEvent may be nested on a single thread.

Events on different threads are tracked independently.

◆ enabled()

static bool G3D::Profiler::enabled ( )
inlinestatic

When disabled no profiling occurs (i.e., beginCPU and beginGFX do nothing).

Since profiling can affect performance (nextFrame() may block), top framerate should be measured with profiling disabled.

◆ endEvent()

static void G3D::Profiler::endEvent ( )
static

Ends the most recent pending event on the current thread.

◆ getEvents()

static void G3D::Profiler::getEvents ( Array< const Array< Event > *> &  eventTrees)
static

Return all events from the previous frame, one array per thread.

The underlying arrays will be mutated when nextFrame() is invoked.

The result has the form: const Profiler::Event& e = (*(eventTrees[threadIndex]))[eventIndex] The events are stored as the depth-first traversal of the event tree. See the Profiler::Event documentation for information about identifying the roots and edges within each tree.

◆ getEventTime()

static void G3D::Profiler::getEventTime ( const String eventName,
RealTime cpuTime,
RealTime gfxTime 
)
static

Returns the sum of all time spent in events with this name (which may be zero, if they do not exist) across all threads.

◆ LAUNCH_SHADER_timingEnabled()

static bool G3D::Profiler::LAUNCH_SHADER_timingEnabled ( )
static

Whether to make profile events in every LAUNCH_SHADER call.

Default is true.

◆ nextFrame()

static void G3D::Profiler::nextFrame ( )
static

Notify the profiler to latch the current event tree.

Events are always presented one frame late so that that information is static and independent of when the caller requests it within the frame.

Invoking nextFrame may stall the GPU and CPU by blocking in the method, causing your net frame time to appear to increase. This is (correctly) not reflected in the values returned by event timers.

GApp calls this automatically. Note that this may cause OpenGL errors and race conditions in programs that use multiple GL contexts if there are any outstanding events on any thread at the time that it is invoked. It is the programmer's responsibility to ensure that that does not happen.

◆ set_LAUNCH_SHADER_timingEnabled()

static void G3D::Profiler::set_LAUNCH_SHADER_timingEnabled ( bool  enabled)
static

Set whether to make profile events in every LAUNCH_SHADER call.

Useful for when you only want to time a small amount of thing, or just the aggregate of many launches.

◆ setEnabled()

static void G3D::Profiler::setEnabled ( bool  e)
static

When disabled no profiling occurs (i.e., beginCPU and beginGFX do nothing).

Since profiling can affect performance (nextFrame() may block), top framerate should be measured with profiling disabled.

◆ threadShutdownHook()

static void G3D::Profiler::threadShutdownHook ( )
static

Do not call directly if using Thread.

Registered with Thread to deallocate the ThreadInfo for a thread. Must be explicitly invoked if you use a different thread API.


documentation generated on Wed Nov 24 2021 08:01:59 using doxygen 1.8.15