Profiler Class Reference

#include <profiler.h>

Detailed Description

Internal.

Public Member Functions

MAXON_METHOD UInt32 GetSampleCount ()
 
MAXON_METHOD void Reset ()
 
MAXON_METHOD Bool GetDebugDumpEnabled ()
 
MAXON_METHOD void SetDebugDumpEnabled (Bool state)
 
MAXON_METHOD PROFILER_STATE GetEnableState ()
 
MAXON_METHOD void SetEnableState (PROFILER_STATE state)
 
MAXON_METHOD Bool GetEnableState (const ProfilingPoint &profilingPoint)
 
MAXON_METHOD void GetMacroTime ()
 
MAXON_METHOD Bool IsFirstTime (const ProfilingPoint &profilingPoint)
 
MAXON_METHOD void AddSample (const ProfilingPoint &profilingPoint)
 
MAXON_METHOD void AddPointSample (const ProfilingPoint &profilingPoint, const Char *outputString=nullptr)
 
MAXON_METHOD void AddPointSample (const ProfilingPoint &profilingPoint, const String &outputString)
 
MAXON_METHOD void OutputString (String &string)
 
MAXON_METHOD void OutputStringReport (const String &headerString)
 
MAXON_METHOD PROFILER_CLOCK_MODE GetClockMode ()
 
MAXON_METHOD void SetClockMode (PROFILER_CLOCK_MODE clockMode)
 
MAXON_METHOD void SetClock (TimeValue timeValue)
 
MAXON_METHOD void SetClockMilliseconds (UInt32 milliseconds)
 
MAXON_METHOD UInt32 GetClockSampleProcessTime ()
 
MAXON_METHOD void SetClockSampleProcessTime (UInt32 milliseconds)
 
MAXON_METHOD UInt32 GetClockAutoIncrementTime ()
 
MAXON_METHOD void SetClockAutoIncrementTime (UInt32 milliseconds)
 
MAXON_METHOD void AddClock (TimeValue timeValue)
 
MAXON_METHOD void AddClockMilliseconds (UInt32 milliseconds)
 
MAXON_METHOD UInt32 GetTimeFilter ()
 
MAXON_METHOD void SetTimeFilter (UInt32 threshold)
 
MAXON_METHOD void GetLock ()
 
MAXON_METHOD void ReleaseLock ()
 

Static Public Member Functions

static const ProfilerNullValueRef ()
 

Private Member Functions

 MAXON_INTERFACE_NONVIRTUAL (Profiler, MAXON_REFERENCE_NONE, "net.maxon.interface.profiler")
 

Member Function Documentation

◆ MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( Profiler  ,
MAXON_REFERENCE_NONE  ,
"net.maxon.interface.profiler"   
)
private

◆ NullValueRef()

static const Profiler& NullValueRef ( )
static

◆ GetSampleCount()

MAXON_METHOD UInt32 GetSampleCount ( )

Gets the count of captured samples.

Returns
Captured sample count.

◆ Reset()

MAXON_METHOD void Reset ( )

Resets the profiler.

◆ GetDebugDumpEnabled()

MAXON_METHOD Bool GetDebugDumpEnabled ( )

Gets the profiler debug dump enabled state.

Returns
True if enabled, false otherwise.

◆ SetDebugDumpEnabled()

MAXON_METHOD void SetDebugDumpEnabled ( Bool  state)

Sets the profiler debug dump enabled state.

Parameters
[in]stateTrue if enabled, false otherwise.

◆ GetEnableState() [1/2]

MAXON_METHOD PROFILER_STATE GetEnableState ( )

Gets the profiler state.

Returns
State: DISABLED, ENABLED_METHOD_SCOPE, ENABLED_ALL

◆ SetEnableState()

MAXON_METHOD void SetEnableState ( PROFILER_STATE  state)

Sets the profiler state.

Parameters
[in]stateState: DISABLED, ENABLED_METHOD_SCOPE, ENABLED_ALL

◆ GetEnableState() [2/2]

MAXON_METHOD Bool GetEnableState ( const ProfilingPoint profilingPoint)

Gets the enabled state of a profiling point.

Returns
True if enabled.

◆ GetMacroTime()

MAXON_METHOD void GetMacroTime ( )

Gets the current time. Used by the calling macro to capture the time before arguments for the call to AddPointSample or AddSample methods are evaluated.

◆ IsFirstTime()

MAXON_METHOD Bool IsFirstTime ( const ProfilingPoint profilingPoint)

Indicates if a profiling point is visited for the first time in the current scope.

Parameters
[in]profilingPointProfilingPoint reference.
Returns
True or false.

◆ AddSample()

MAXON_METHOD void AddSample ( const ProfilingPoint profilingPoint)

Adds a sample to a profiling point in the current scope.

A profiling point may be visited multiple times during execution, e.g. within a loop. Every encounter records a time measurement sample, which is added to the scope point, and is used to calculate the total and average time for all captured samples. Points of METHOD_ENTER or SCOPE_ENTER types capture the total scope time for every sample, allowing to report the average scope time as well.

Parameters
[in]profilingPointProfilingPoint reference.

◆ AddPointSample() [1/2]

MAXON_METHOD void AddPointSample ( const ProfilingPoint profilingPoint,
const Char outputString = nullptr 
)

Adds a profiling point to the current scope and registers a sample.

A profiling point is declared by using a PROFILER macro with an optional output string to be printed with the trace report. If present, the string is recorded the first time a profiling point is visited per scope.

The following example gets the global profiler, configures it to use a simulated clock (to force the captured time values to be constant) and defines profiling points to run the following sequence:

ME 5ms SE loop5x{ 10ms D } 5ms SL ML

where:

  • ME = METHOD_ENTER
  • #ms = time delta in milliseconds
  • SE = SCOPE_ENTER
  • D = DELTA
  • SL = SCOPE_LEAVE
  • ML = METHOD_LEAVE
static void MyMethod()
{
maxon::Profiler& profiler = *maxon::ProfilerInstance();
// capture all profiling point types
// use simulated clock
// set sample processing simulated time (in milliseconds)
// set the time filtering threshold
profiler.SetTimeFilter(0);
profiler.AddClockMilliseconds(5);
PROFILER_SCOPE_ENTER("Number of loops: 5"_s);
for (Int32 index = 0; index < 5; index++)
{
profiler.AddClockMilliseconds(10);
}
profiler.AddClockMilliseconds(5);
profiler.OutputStringReport("MyMethod - Profile trace dump"_s);
}
Internal.
Definition: profiler.h:60
MAXON_METHOD void OutputStringReport(const String &headerString)
MAXON_METHOD void SetClockMode(PROFILER_CLOCK_MODE clockMode)
MAXON_METHOD void SetClockSampleProcessTime(UInt32 milliseconds)
Sets the profiler simulated clock time to process a sample.
MAXON_METHOD void SetEnableState(PROFILER_STATE state)
MAXON_METHOD void SetTimeFilter(UInt32 threshold)
MAXON_METHOD void AddClockMilliseconds(UInt32 milliseconds)
Adds a time delta in milliseconds to the profiler simulated clock.
Py_ssize_t * index
Definition: abstract.h:374
maxon::Int32 Int32
Definition: ge_sys_math.h:60
@ ENABLED_ALL
Enabled for all point types.
@ SIMULATED
Use a simulated clock for profiling purpose.
#define PROFILER_SCOPE_ENTER(...)
Definition: profiler.h:422
#define PROFILER_SCOPE_LEAVE(...)
Definition: profiler.h:423
#define PROFILER_METHOD(...)
Definition: profiler.h:427
#define PROFILER_DELTA(...)
Definition: profiler.h:424

Produces the following output:

MyMethod - Profile trace dump (8 samples in 4 points) [>] 60.0 ms (100.00%), 0.00 ns (0.00% profiler) : METHOD_ENTER: MyMethod (line 304) [0] 5.0 ms (8.33%) [0] 55.0 ms (91.67%), 80.00 ms (31.25% profiler): SCOPE_ENTER: MyMethod (line 308) - Number of loops: 5 [1] 50.0 ms (90.91%) avg: 10.0 ms (5 samples): DELTA: MyMethod (line 314) [1] 5.0 ms (9.09%): SCOPE_LEAVE: MyMethod (line 319)

Parameters
[in]profilingPointProfilingPoint reference.
[in]outputStringOptional string to be printed when outputting a report.

◆ AddPointSample() [2/2]

MAXON_METHOD void AddPointSample ( const ProfilingPoint profilingPoint,
const String outputString 
)

◆ OutputString()

MAXON_METHOD void OutputString ( String string)

Outputs a string to the debugger output and the C4D console profiler logger.

Parameters
[in]stringString to output.

◆ OutputStringReport()

MAXON_METHOD void OutputStringReport ( const String headerString)

Outputs a profiling trace to the debugger output and the C4D console profiler logger.

Parameters
[in]headerStringHeader string to output first.

◆ GetClockMode()

Gets the profiler clock mode.

Returns
State: NORMAL, SIMULATED

◆ SetClockMode()

MAXON_METHOD void SetClockMode ( PROFILER_CLOCK_MODE  clockMode)

Sets the profiler clock mode.

Parameters
[in]clockModeState: NORMAL, SIMULATED

◆ SetClock()

MAXON_METHOD void SetClock ( TimeValue  timeValue)

Sets the profiler simulated clock time value.

◆ SetClockMilliseconds()

MAXON_METHOD void SetClockMilliseconds ( UInt32  milliseconds)

Sets the profiler simulated clock to a time value in milliseconds.

◆ GetClockSampleProcessTime()

MAXON_METHOD UInt32 GetClockSampleProcessTime ( )

Gets the profiler simulated clock time to process a sample in milliseconds.

Returns
Sample process time

◆ SetClockSampleProcessTime()

MAXON_METHOD void SetClockSampleProcessTime ( UInt32  milliseconds)

Sets the profiler simulated clock time to process a sample.

◆ GetClockAutoIncrementTime()

MAXON_METHOD UInt32 GetClockAutoIncrementTime ( )

Gets the profiler simulated clock automatic time increment.

Returns
Clock automatic time increment value

◆ SetClockAutoIncrementTime()

MAXON_METHOD void SetClockAutoIncrementTime ( UInt32  milliseconds)

Sets the profiler simulated clock automatic time increment.

◆ AddClock()

MAXON_METHOD void AddClock ( TimeValue  timeValue)

Adds a time value to the profiler simulated clock.

◆ AddClockMilliseconds()

MAXON_METHOD void AddClockMilliseconds ( UInt32  milliseconds)

Adds a time delta in milliseconds to the profiler simulated clock.

◆ GetTimeFilter()

MAXON_METHOD UInt32 GetTimeFilter ( )

Gets the time filter threshold value in milliseconds.

Returns
Time filter threshold value.

◆ SetTimeFilter()

MAXON_METHOD void SetTimeFilter ( UInt32  threshold)

Sets the time filter threshold value in milliseconds.

Parameters
[in]thresholdState.

◆ GetLock()

MAXON_METHOD void GetLock ( )

Get a lock on the profiler.

◆ ReleaseLock()

MAXON_METHOD void ReleaseLock ( )

Releases a lock on the profiler.