PC Stable Documentation
 
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Loading...
Searching...
No Matches
Enforce Script profiling API

Data Structures

class  EnProfiler
 Set of methods for accessing script profiling data. More...
 

Typedefs

typedef Param2< float, typenameEnProfilerTimeClassPair
 
typedef Param2< int, typenameEnProfilerCountClassPair
 
typedef Param2< float, stringEnProfilerTimeFuncPair
 
typedef Param2< int, stringEnProfilerCountFuncPair
 

Enumerations

enum  EnProfilerFlags { NONE = 0 , RESET , RECURSIVE , ALL }
 Flags that influences the behaviour of the EnProfiler API, applied through ...Flags functions. More...
 
enum  EnProfilerModule {
  CORE , GAMELIB , GAME , WORLD ,
  MISSION , MISSION_CUSTOM , ERROR
}
 Current base scripted modules. More...
 
enum  EnProfilerEnabledFlags { NONE = 0 , DIAG , SCRP , SCRC }
 There are 3 states which can be toggled that governs whether script profiling is enabled or not. More...
 

Functions

static proto void Enable (bool enable, bool immediate=false, bool sessionReset=true)
 Enable the gathering of script profiling data.
 
static proto int IsEnabled ()
 Return if script profiling is enabled.
 
static bool IsEnabledD ()
 Return if script profiling is enabled through [DM].
 
static bool IsEnabledP ()
 Return if script profiling is enabled through EnProfiler.
 
static bool IsEnabledC ()
 Return if script profiling is actually turned on inside of the script context.
 
static proto void SortData ()
 The internal sorting that happens at the end of the frame (so it is NOT necessary to call this manually) to supply Get...Per... functions.
 
static proto void ResetSession (bool fullReset=false)
 Perform [SR], clearing SessionFrame, ProfiledSessionFrames, [SD] and [PD] (except for [CI])
 

EnProfilerFlags

Set of functions to configure the currently active EnProfilerFlags

static proto int SetFlags (int flags, bool sessionReset=true)
 Override the currently used set of EnProfilerFlags across the API.
 
static proto int GetFlags ()
 Get the currently used flags across the API.
 
static proto bool IsFlagsSet (int flags)
 Check if the flags are set.
 
static proto int AddFlags (int flags, bool sessionReset=true)
 Add flags to the currently used set of EnProfilerFlags across the API.
 
static proto int RemoveFlags (int flags, bool sessionReset=true)
 Remove flags from the currently used set of EnProfilerFlags across the API.
 
static proto int ClearFlags (bool sessionReset=true)
 Remove all flags from the currently used set of EnProfilerFlags across the API.
 

EnProfilerModule

Set of functions to configure the currently profiled EnProfilerModule

static proto void SetModule (EnProfilerModule module, bool sessionReset=true)
 Set the module to be profiled.
 
static proto EnProfilerModule GetModule ()
 Get the currently profiled module.
 
static proto owned string ModuleToName (EnProfilerModule module)
 Helper to convert EnProfilerModule to string.
 
static proto bool NameToModule (string moduleName, out EnProfilerModule module)
 Convert string to EnProfilerModule.
 
static proto void SetInterval (int interval, bool sessionReset=true)
 Set the interval for the [SD] to update.
 
static proto int GetInterval ()
 Get the currently set interval.
 
static proto void SetTimeResolution (int resolution)
 Set the resolution of the fetched Time data.
 
static proto int GetTimeResolution ()
 Get the currently set time resolution.
 
static proto void EnableAverage (bool enable)
 Enable/disable returning calculated averages.
 
static proto bool IsAverage ()
 Check if returning of average data is enabled.
 
static proto void Dump ()
 Print out [SD] to script log.
 

Frame data

Set of functions to obtain information about frame counts

static proto int GetGameFrame ()
 Get the total amount of frames passed.
 
static proto int GetSessionFrame ()
 Get the total amount of frames in this profiling session.
 
static proto int GetTotalFrames ()
 Get the total amount of frames across all profiling session.
 
static proto int GetProfiledSessionFrames ()
 Get the total amount of frames profiled in this profiling session.
 
static proto int GetProfiledFrames ()
 Get the total amount of frames profiled across all profiling session.
 

Sorted data

Set of functions to obtain [SD]

Warning
Data is appended to the array, it will not clear any previous data already existing in the array
Note
Read SortData as well for more information regarding [SD]
static proto void GetTimePerClass (notnull out array< ref EnProfilerTimeClassPair > outArr, int count=int.MAX)
 Obtain [SD] for Time Per Class.
 
static proto void GetAllocationsPerClass (notnull out array< ref EnProfilerCountClassPair > outArr, int count=int.MAX)
 Obtain [SD] for Allocations Per Class.
 
static proto void GetInstancesPerClass (notnull out array< ref EnProfilerCountClassPair > outArr, int count=int.MAX)
 Obtain [SD] for Instances Per Class.
 
static proto void GetTimePerFunc (notnull out array< ref EnProfilerTimeFuncPair > outArr, int count=int.MAX)
 Obtain [SD] for Time Per Function.
 
static proto void GetCountPerFunc (notnull out array< ref EnProfilerCountFuncPair > outArr, int count=int.MAX)
 Obtain [SD] for Count Per Function.
 

Specific data

Set of functions to obtain specific data

static proto float GetTimeOfClass (typename clss, bool immediate=false)
 Obtain [SD] or [PD] regarding the time a specific class consumed.
 
static proto int GetAllocationsOfClass (typename clss, bool immediate=false)
 Obtain [SD] or [PD] regarding the allocations of a specific class.
 
static proto int GetInstancesOfClass (typename clss, bool immediate=false)
 Obtain [SD] or [PD] regarding the [CI] of a specific class.
 
static proto float GetTimeOfFunc (string funct, typename clss, bool immediate=false)
 Obtain [SD] or [PD] regarding the time consumed by a specific function.
 
static proto float GetTimeOfFuncG (string funct, bool immediate=false)
 Obtain [SD] or [PD] regarding the time consumed by a specific global function.
 
static proto int GetCountOfFunc (string funct, typename clss, bool immediate=false)
 Obtain [SD] or [PD] regarding the amount of times a specific function was called.
 
static proto int GetCountOfFuncG (string funct, bool immediate=false)
 Obtain [SD] or [PD] regarding the amount of times a specific function was called.
 

Misc

Set of helper functions

static bool RequestImmediateData ()
 Helper method to ascertain the profiler will record [PD] right after this call.
 

Detailed Description

Warning
Only available on developer and diag builds

Typedef Documentation

◆ EnProfilerCountClassPair

◆ EnProfilerCountFuncPair

◆ EnProfilerTimeClassPair

◆ EnProfilerTimeFuncPair

Enumeration Type Documentation

◆ EnProfilerEnabledFlags

There are 3 states which can be toggled that governs whether script profiling is enabled or not.

Note
The reason for this is because when it is enabled in debug menu, or through this API without 'immediate', it will only be enabled the next frame
Enumerator
NONE 

No flags.

No automatic destroying.

Flags to pass to ParticleSource.StopParticle.

Plain Effect base.

No flags, has value 0, so will count as false in conditions.

No flags

DIAG 

Script profiling UI is enabled in WIN+ALT debug menu, when this is true, it will override SCRP.

SCRP 

It has been set to being always enabled through EnProfiler (SCRipt Profiler)

SCRC 

Whether profiling is currently truly happening (SCRipt Context)

◆ EnProfilerFlags

Flags that influences the behaviour of the EnProfiler API, applied through ...Flags functions.

Enumerator
NONE 

No flags.

No automatic destroying.

Flags to pass to ParticleSource.StopParticle.

Plain Effect base.

No flags, has value 0, so will count as false in conditions.

No flags

RESET 

When present, will reset [PD] on sorting, otherwise will accumulate on top of it.

RECURSIVE 

Whether to profile child modules.

ALL 

All flags enabled.

◆ EnProfilerModule

Current base scripted modules.

Enumerator
CORE 

1_Core

GAMELIB 

2_GameLib

GAME 

3_Game

WORLD 

4_World

MISSION 

5_Mission

MISSION_CUSTOM 

init.c

ERROR 

Can be returned from some methods.

Function Documentation

◆ AddFlags()

static proto int AddFlags ( int  flags,
bool  sessionReset = true 
)
staticprivate

Add flags to the currently used set of EnProfilerFlags across the API.

Note
Simply a helper method to quickly add EnProfilerFlags
Parameters
flagsint The combination of desired EnProfilerFlags to be added to the currently used set
sessionResetbool When set to false, no [SR] will trigger, regardless of situation
Returns
int The currently used set of EnProfilerFlags after the function call
// In the case where the current set of EnProfilerFlags is EnProfilerFlags.RESET
// The resulting set of flags now will be EnProfilerFlags.RESET | EnProfilerFlags.RECURSIVE
// As the above is pretty much the same as the following
// EnProfiler.SetFlags(EnProfiler.GetFlags() | EnProfilerFlags.RECURSIVE);
// But a much cleaner and faster alternative (bitwise operations in script is ~10x slower than C++)
Set of methods for accessing script profiling data.
Definition EnProfiler.c:73
static proto int AddFlags(int flags, bool sessionReset=true)
Add flags to the currently used set of EnProfilerFlags across the API.
EnProfilerFlags
Flags that influences the behaviour of the EnProfiler API, applied through ...Flags functions.
Definition EnProfiler.c:9

Referenced by EnProfilerTests::TestAddFlags().

◆ ClearFlags()

static proto int ClearFlags ( bool  sessionReset = true)
staticprivate

Remove all flags from the currently used set of EnProfilerFlags across the API.

Note
Simply a helper method to quickly remove all EnProfilerFlags
Parameters
sessionResetbool When set to false, no [SR] will trigger, regardless of situation
Returns
int The currently used set of EnProfilerFlags after the function call
// In the case where the current set of EnProfilerFlags is EnProfilerFlags.RESET
// The resulting set of flags now will be EnProfilerFlags.NONE
// As the above is pretty much the same as the following
// EnProfiler.SetFlags(EnProfilerFlags.NONE);
// But a much cleaner and implicit alternative
static proto int ClearFlags(bool sessionReset=true)
Remove all flags from the currently used set of EnProfilerFlags across the API.

Referenced by EnProfilerTests::TestAddFlags(), and EnProfilerTests::TestClearFlags().

◆ Dump()

static proto void Dump ( )
staticprivate

Print out [SD] to script log.

static proto void Dump()
Print out [SD] to script log.

◆ Enable()

static proto void Enable ( bool  enable,
bool  immediate = false,
bool  sessionReset = true 
)
staticprivate

Enable the gathering of script profiling data.

Note
DEFAULT: disabled (unless launched with "-profile", then it is default enabled)
This is separate from the one in [DM], so toggling it in [DM] will not affect this, and toggling it here will not affect [DM]
It will ignore the call if trying to set the current state, except when "immediate" is used
Parameters
enablebool Whether to enable or disable, if it was previously not enabled, it will cause [SR]
Note
Disabling does not cause [SR], so all data will stay intact
Parameters
immediatebool When true will instantly start/stop profiling, otherwise it will apply it at the end of the frame (to have one stable point in time)
Warning
Keep in mind that when using immediate, it will not be the data of the entire frame, which can skew data if not kept in mind
Parameters
sessionResetbool When set to false, no [SR] will trigger, regardless of situation
// Simple enable, will start profiling the next frame
// Will cause [SR] if !IsEnabledP() before this call
// Immediate enable, will start profiling immediately
// Will cause [SR] if !IsEnabledP() before this call
EnProfiler.Enable(true, true);
// Immediate disable, will stop profiling immediately
// Disabling will never cause [SR], preserving data
EnProfiler.Enable(false, true);
// Simple disable, will not profile the next frame (but still finish profiling the current one)
// Disabling will never cause [SR], preserving data
static proto void Enable(bool enable, bool immediate=false, bool sessionReset=true)
Enable the gathering of script profiling data.

Referenced by EnProfiler::RequestImmediateData(), EnProfilerTests::TestClassCountData(), EnProfilerTests::TestClassTimeData(), EnProfilerTests::TestFuncCountData(), EnProfilerTests::TestFuncTimeData(), EnProfilerTests::TestModule(), EnProfilerTests::TestToggling(), EnProfilerTests::TestTogglingImmediate(), and EnProfilerTests::~EnProfilerTests().

◆ EnableAverage()

static proto void EnableAverage ( bool  enable)
staticprivate

Enable/disable returning calculated averages.

Note
DEFAULT: false
When EnProfilerFlags.RESET flag is not present, it will divide by the session frame
When an interval is set, it will divide by the interval
Does not affect any data itself, only the fetching and displaying of it (therefore, no [SR] is ever triggered by this method)
[CI] will never be an average, it will always be the current count of the instance (allocations will be the value of how many times an instance is created)
Parameters
enablebool Whether to enable or disable
// For example, take the situation where we only reset every 60 frames
// And a method is called once per frame, gathering the count of that function will be 1
// Or if a method is called twice per frame, gathering the count of that function will be 2
// Or if a method is 3 times every 3 frames, gathering the count of that function will be 1
// ...
// So you get the average amount of times the method is called per frame, out of the sample of 60 frames
static proto void EnableAverage(bool enable)
Enable/disable returning calculated averages.
static proto void SetInterval(int interval, bool sessionReset=true)
Set the interval for the [SD] to update.

◆ GetAllocationsOfClass()

static proto int GetAllocationsOfClass ( typename clss  ,
bool  immediate = false 
)
staticprivate

Obtain [SD] or [PD] regarding the allocations of a specific class.

Parameters
clsstypename Typename of desired class
immediatebool When true, it will pull from [SD], when false it will pull from [PD]
Returns
int Allocations of the specified class
int allocationsOfClass = EnProfiler.GetAllocationsOfClass(StaticGetType(EPTHelperClass), true);
static proto int GetAllocationsOfClass(typename clss, bool immediate=false)
Obtain [SD] or [PD] regarding the allocations of a specific class.

Referenced by EnProfilerTests::TestClassCountData().

◆ GetAllocationsPerClass()

static proto void GetAllocationsPerClass ( notnull out array< ref EnProfilerCountClassPair outArr,
int  count = int.MAX 
)
staticprivate

Obtain [SD] for Allocations Per Class.

Parameters
outArrarray<ref EnProfilerCountClassPair> Array sorted by number of allocations of a class
countint The maximum amount of entries wanted
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition IsBoxCollidingGeometryProxyClasses.c:28
static proto void GetAllocationsPerClass(notnull out array< ref EnProfilerCountClassPair > outArr, int count=int.MAX)
Obtain [SD] for Allocations Per Class.

◆ GetCountOfFunc()

static proto int GetCountOfFunc ( string  funct,
typename clss  ,
bool  immediate = false 
)
staticprivate

Obtain [SD] or [PD] regarding the amount of times a specific function was called.

Parameters
functstring Function name
clsstypename Typename of class the function belongs to
immediatebool When true, it will pull from [SD], when false it will pull from [PD]
Returns
int Amount of calls to the specified function or -1 when function was not found
int callCountOfFunc = EnProfiler.GetCountOfFunc("StringFormat", StaticGetType(EnProfilerTests), true);
Definition EnProfilerTests.c:2
static proto int GetCountOfFunc(string funct, typename clss, bool immediate=false)
Obtain [SD] or [PD] regarding the amount of times a specific function was called.

Referenced by EnProfilerTests::TestFuncCountData().

◆ GetCountOfFuncG()

static proto int GetCountOfFuncG ( string  funct,
bool  immediate = false 
)
staticprivate

Obtain [SD] or [PD] regarding the amount of times a specific function was called.

Parameters
functstring Function name
immediatebool When true, it will pull from [SD], when false it will pull from [PD]
Returns
int Amount of calls to the specified function or -1 when function was not found
int callCountOfFunc = EnProfiler.GetCountOfFuncG("ErrorEx", true);
static proto int GetCountOfFuncG(string funct, bool immediate=false)
Obtain [SD] or [PD] regarding the amount of times a specific function was called.

Referenced by EnProfilerTests::TestFuncCountData().

◆ GetCountPerFunc()

static proto void GetCountPerFunc ( notnull out array< ref EnProfilerCountFuncPair outArr,
int  count = int.MAX 
)
staticprivate

Obtain [SD] for Count Per Function.

Parameters
outArrarray<ref EnProfilerCountFuncPair> Array sorted by amount of times a function was called
countint The maximum amount of entries wanted
EnProfiler.GetCountPerFunc(countPerFunc, 20);
static proto void GetCountPerFunc(notnull out array< ref EnProfilerCountFuncPair > outArr, int count=int.MAX)
Obtain [SD] for Count Per Function.

◆ GetFlags()

static proto int GetFlags ( )
staticprivate

Get the currently used flags across the API.

Returns
int The currently used set of EnProfilerFlags
int flags = EnProfiler.GetFlags();
if (flags & EnProfilerFlags.RECURSIVE)
{
Print("Currently profiling all modules.");
}
proto void Print(void var)
Prints content of variable to console/log.
static proto int GetFlags()
Get the currently used flags across the API.

Referenced by EnProfilerTests::TestAddFlags(), EnProfilerTests::TestClearFlags(), EnProfilerTests::TestModule(), and EnProfilerTests::TestSetFlags().

◆ GetGameFrame()

static proto int GetGameFrame ( )
staticprivate

Get the total amount of frames passed.

Returns
int The total amount of frames passed
int gameFrame = EnProfiler.GetGameFrame();
static proto int GetGameFrame()
Get the total amount of frames passed.

◆ GetInstancesOfClass()

static proto int GetInstancesOfClass ( typename clss  ,
bool  immediate = false 
)
staticprivate

Obtain [SD] or [PD] regarding the [CI] of a specific class.

Parameters
clsstypename Typename of desired class
immediatebool When true, it will pull from [SD], when false it will pull from [PD]
Returns
int [CI] of the specified class
int instancesOfClass = EnProfiler.GetInstancesOfClass(StaticGetType(EPTHelperClass), true);
static proto int GetInstancesOfClass(typename clss, bool immediate=false)
Obtain [SD] or [PD] regarding the [CI] of a specific class.

Referenced by EnProfilerTests::TestClassCountData().

◆ GetInstancesPerClass()

static proto void GetInstancesPerClass ( notnull out array< ref EnProfilerCountClassPair outArr,
int  count = int.MAX 
)
staticprivate

Obtain [SD] for Instances Per Class.

Parameters
outArrarray<ref EnProfilerCountClassPair> Array sorted by number of instances of a class
countint The maximum amount of entries wanted
array<ref EnProfilerCountClassPair> instancesPerClass = {};
EnProfiler.GetInstancesPerClass(instancesPerClass, 20);
static proto void GetInstancesPerClass(notnull out array< ref EnProfilerCountClassPair > outArr, int count=int.MAX)
Obtain [SD] for Instances Per Class.

◆ GetInterval()

static proto int GetInterval ( )
staticprivate

Get the currently set interval.

Returns
int The currently set interval
int currentInterval = EnProfiler.GetInterval();
static proto int GetInterval()
Get the currently set interval.

◆ GetModule()

static proto EnProfilerModule GetModule ( )
staticprivate

Get the currently profiled module.

Returns
EnProfilerModule The currently profiled module
static proto EnProfilerModule GetModule()
Get the currently profiled module.
EnProfilerModule
Current base scripted modules.
Definition EnProfiler.c:22

Referenced by EnProfilerTests::TestModule().

◆ GetProfiledFrames()

static proto int GetProfiledFrames ( )
staticprivate

Get the total amount of frames profiled across all profiling session.

Note
This will only differ from GetTotalFrames when there was an Interval set at some point
Returns
int The total amount of frames profiled across all profiling session
int totalProfiledFrames = EnProfiler.GetProfiledFrames();
static proto int GetProfiledFrames()
Get the total amount of frames profiled across all profiling session.

◆ GetProfiledSessionFrames()

static proto int GetProfiledSessionFrames ( )
staticprivate

Get the total amount of frames profiled in this profiling session.

Note
This will only differ from GetSessionFrame when there is an Interval set
Returns
int The total amount of frames profiled in this profiling session
int profiledSessionFrames = EnProfiler.GetProfiledSessionFrames();
static proto int GetProfiledSessionFrames()
Get the total amount of frames profiled in this profiling session.

◆ GetSessionFrame()

static proto int GetSessionFrame ( )
staticprivate

Get the total amount of frames in this profiling session.

Note
This will only differ from GetProfiledSessionFrames when there is an Interval set
Returns
int The total amount of frames in this profiling session
int sessionFrame = EnProfiler.GetSessionFrame();
static proto int GetSessionFrame()
Get the total amount of frames in this profiling session.

◆ GetTimeOfClass()

static proto float GetTimeOfClass ( typename clss  ,
bool  immediate = false 
)
staticprivate

Obtain [SD] or [PD] regarding the time a specific class consumed.

Parameters
clsstypename Typename of desired class
immediatebool When true, it will pull from [SD], when false it will pull from [PD]
Returns
float Time consumed by the specified class
// Consider the class
EPTHelperClass clss = new EPTHelperClass();
// Some functions being called here...
// Gathering of data can be done through
float timeOfClass = EnProfiler.GetTimeOfClass(clss.Type(), true);
// Or when you have no variable/reference
float timeOfClass2 = EnProfiler.GetTimeOfClass(StaticGetType(EPTHelperClass), true);
static proto float GetTimeOfClass(typename clss, bool immediate=false)
Obtain [SD] or [PD] regarding the time a specific class consumed.

Referenced by EnProfilerTests::TestClassTimeData().

◆ GetTimeOfFunc()

static proto float GetTimeOfFunc ( string  funct,
typename clss  ,
bool  immediate = false 
)
staticprivate

Obtain [SD] or [PD] regarding the time consumed by a specific function.

Parameters
functstring Function name
clsstypename Typename of class the function belongs to
immediatebool When true, it will pull from [SD], when false it will pull from [PD]
Returns
float Time consumed by the specified function or -1 when function was not found
float timeOfFunc = EnProfiler.GetTimeOfFunc("StringFormat", StaticGetType(EnProfilerTests), true);
static proto float GetTimeOfFunc(string funct, typename clss, bool immediate=false)
Obtain [SD] or [PD] regarding the time consumed by a specific function.

Referenced by EnProfilerTests::TestFuncTimeData(), and EnProfilerTests::TestModule().

◆ GetTimeOfFuncG()

static proto float GetTimeOfFuncG ( string  funct,
bool  immediate = false 
)
staticprivate

Obtain [SD] or [PD] regarding the time consumed by a specific global function.

Parameters
functstring Function name
immediatebool When true, it will pull from [SD], when false it will pull from [PD]
Returns
float Time consumed by the specified function or -1 when function was not found
float timeOfFunc = EnProfiler.GetTimeOfFuncG("ErrorEx", true);
static proto float GetTimeOfFuncG(string funct, bool immediate=false)
Obtain [SD] or [PD] regarding the time consumed by a specific global function.

◆ GetTimePerClass()

static proto void GetTimePerClass ( notnull out array< ref EnProfilerTimeClassPair outArr,
int  count = int.MAX 
)
staticprivate

Obtain [SD] for Time Per Class.

Parameters
outArrarray<ref EnProfilerTimeClassPair> Array sorted by time consumed by a class
countint The maximum amount of entries wanted
// In this example the array will be filled with the 20 most time intensive classes
// If there are less than 20 classes which consumed time, it will output that number of classes instead
EnProfiler.GetTimePerClass(timePerClass, 20);
// In this example the array will be filled with all classes sorted by time
EnProfiler.GetTimePerClass(timePerClass2);
static proto void GetTimePerClass(notnull out array< ref EnProfilerTimeClassPair > outArr, int count=int.MAX)
Obtain [SD] for Time Per Class.

Referenced by EnProfilerTests::TestModule().

◆ GetTimePerFunc()

static proto void GetTimePerFunc ( notnull out array< ref EnProfilerTimeFuncPair outArr,
int  count = int.MAX 
)
staticprivate

Obtain [SD] for Time Per Function.

Parameters
outArrarray<ref EnProfilerTimeFuncPair> Array sorted by time consumed by a function
countint The maximum amount of entries wanted
EnProfiler.GetTimePerFunc(timePerFunc, 20);
static proto void GetTimePerFunc(notnull out array< ref EnProfilerTimeFuncPair > outArr, int count=int.MAX)
Obtain [SD] for Time Per Function.

Referenced by EnProfilerTests::TestModule().

◆ GetTimeResolution()

static proto int GetTimeResolution ( )
staticprivate

Get the currently set time resolution.

Returns
int The currently set resolution
int currentTimeResolution = EnProfiler.GetTimeResolution();
static proto int GetTimeResolution()
Get the currently set time resolution.

Referenced by EnProfilerTests::TestClassTimeData(), EnProfilerTests::TestFuncTimeData(), and EnProfilerTests::TestModule().

◆ GetTotalFrames()

static proto int GetTotalFrames ( )
staticprivate

Get the total amount of frames across all profiling session.

Note
This will only differ from GetProfiledFrames when there was an Interval set at some point
Returns
int The total amount of frames across all profiling session
int totalFrames = EnProfiler.GetTotalFrames();
static proto int GetTotalFrames()
Get the total amount of frames across all profiling session.

◆ IsAverage()

static proto bool IsAverage ( )
staticprivate

Check if returning of average data is enabled.

Returns
bool Whether returning of average data is enabled
bool isDataAverage = EnProfiler.IsAverage();
static proto bool IsAverage()
Check if returning of average data is enabled.

◆ IsEnabled()

static proto int IsEnabled ( )
staticprivate

Return if script profiling is enabled.

Note
Helper methods below
Returns
int Flags regarding the current state
int isScriptProfilingEnabled = EnProfiler.IsEnabled();
static proto int IsEnabled()
Return if script profiling is enabled.

Referenced by EnProfiler::IsEnabledC(), EnProfiler::IsEnabledD(), and EnProfiler::IsEnabledP().

◆ IsEnabledC()

static bool IsEnabledC ( )
inlinestaticprivate

Return if script profiling is actually turned on inside of the script context.

Note
When using "-profile" launch parameter, it will enable it through EnProfiler, so this will return true
Returns
bool Whether script is being profiled as of this moment
bool isScriptProfilingEnabled = EnProfiler.IsEnabledC();
static bool IsEnabledC()
Return if script profiling is actually turned on inside of the script context.
Definition EnProfiler.c:152

References EnProfiler::IsEnabled().

Referenced by EnProfilerTests::EnProfilerTests(), EnProfiler::RequestImmediateData(), and EnProfilerTests::TestTogglingImmediate().

◆ IsEnabledD()

static bool IsEnabledD ( )
inlinestaticprivate

Return if script profiling is enabled through [DM].

Returns
bool Whether script profiling is enabled through [DM]
bool isScriptProfilingDiagEnabled = EnProfiler.IsEnabledD();
static bool IsEnabledD()
Return if script profiling is enabled through [DM].
Definition EnProfiler.c:124

References EnProfiler::IsEnabled().

◆ IsEnabledP()

static bool IsEnabledP ( )
inlinestaticprivate

Return if script profiling is enabled through EnProfiler.

Note
When using "-profile" launch parameter, it will enable it through EnProfiler, so this will return true
Returns
bool Whether script profiling is enabled through script profiler
bool isScriptProfilingToggleEnabled = EnProfiler.IsEnabledP();
static bool IsEnabledP()
Return if script profiling is enabled through EnProfiler.
Definition EnProfiler.c:138

References EnProfiler::IsEnabled().

Referenced by EnProfilerTests::TestToggling().

◆ IsFlagsSet()

static proto bool IsFlagsSet ( int  flags)
staticprivate

Check if the flags are set.

Note
Is effectively the same as the code displayed in GetFlags example, but without the bitwise operation
Parameters
flagsint The combination of EnProfilerFlags to check if present
Returns
bool If the flags are set
{
Print("Currently all flags are enabled.");
}
{
Print("Currently profiling all modules.");
}
static proto bool IsFlagsSet(int flags)
Check if the flags are set.

◆ ModuleToName()

static proto owned string ModuleToName ( EnProfilerModule  module)
staticprivate

Helper to convert EnProfilerModule to string.

Parameters
moduleEnProfilerModule The module to get the name of
Returns
string The name of the module
string moduleName = EnProfiler.ModuleToName(EnProfilerModule.GAME);
static proto owned string ModuleToName(EnProfilerModule module)
Helper to convert EnProfilerModule to string.

◆ NameToModule()

static proto bool NameToModule ( string  moduleName,
out EnProfilerModule  module 
)
staticprivate

Convert string to EnProfilerModule.

Parameters
moduleNamestring The name of the module
moduleEnProfilerModule The enum value of the module or EnProfilerModule.ERROR if not found
Returns
bool Whether the module was found
// Get the name of the module of the current class
string nameOfCurrentModule = Type().GetModule();
// Convert it to the enum value
if (EnProfiler.NameToModule(nameOfCurrentModule, module))
{
}
else
{
ErrorEx(string.Format("Could not find EnProfilerModule: %1", nameOfCurrentModule));
}
string Type
Definition JsonDataContaminatedArea.c:11
enum ShapeType ErrorEx
static proto void SetModule(EnProfilerModule module, bool sessionReset=true)
Set the module to be profiled.
static proto bool NameToModule(string moduleName, out EnProfilerModule module)
Convert string to EnProfilerModule.

Referenced by EnProfilerTests::TestModule().

◆ RemoveFlags()

static proto int RemoveFlags ( int  flags,
bool  sessionReset = true 
)
staticprivate

Remove flags from the currently used set of EnProfilerFlags across the API.

Note
Simply a helper method to quickly remove EnProfilerFlags
Parameters
flagsint The combination of desired EnProfilerFlags to be added to the currently used set
sessionResetbool When set to false, no [SR] will trigger, regardless of situation
Returns
int The currently used set of EnProfilerFlags after the function call
// In the case where the current set of EnProfilerFlags is EnProfilerFlags.RESET
// The resulting set of flags now will be EnProfilerFlags.NONE
// As the above is pretty much the same as the following
// EnProfiler.SetFlags(EnProfiler.GetFlags() & ~EnProfilerFlags.RECURSIVE);
// But a much cleaner and faster alternative (bitwise operations in script is ~10x slower than C++)
static proto int RemoveFlags(int flags, bool sessionReset=true)
Remove flags from the currently used set of EnProfilerFlags across the API.

Referenced by EnProfilerTests::TestClearFlags(), and EnProfilerTests::TestModule().

◆ RequestImmediateData()

static bool RequestImmediateData ( )
inlinestaticprivate

Helper method to ascertain the profiler will record [PD] right after this call.

Returns
bool Whether it was enabled before or not
bool wasEnabled = EnProfiler.RequestImmediateData();
static bool RequestImmediateData()
Helper method to ascertain the profiler will record [PD] right after this call.
Definition EnProfiler.c:745

References EnProfiler::Enable(), and EnProfiler::IsEnabledC().

Referenced by EnProfilerTests::TestClassCountData(), EnProfilerTests::TestClassTimeData(), EnProfilerTests::TestFuncCountData(), EnProfilerTests::TestFuncTimeData(), and EnProfilerTests::TestModule().

◆ ResetSession()

static proto void ResetSession ( bool  fullReset = false)
staticprivate

Perform [SR], clearing SessionFrame, ProfiledSessionFrames, [SD] and [PD] (except for [CI])

Note
Can also be triggered by a variety of other functions in this API
When triggered by the other functions, it will call with fullReset = false
Parameters
fullResetbool Whether to clear [PD] of all modules, when false it will only clear the [PD] according to current settings
// Considering the settings: SetFlags(EnProfilerFlags.NONE) and SetModule(EnProfilerModule.GAME)
// The following call will only clear [PD] of 3_Game
// Considering the settings: SetFlags(EnProfilerFlags.RECURSIVE) and SetModule(EnProfilerModule.WORLD)
// The following call will clear [PD] of 3_Game, 4_World, 5_Mission and their children
// The following call resets [PD] across all modules
static proto void ResetSession(bool fullReset=false)
Perform [SR], clearing SessionFrame, ProfiledSessionFrames, [SD] and [PD] (except for [CI])

Referenced by EnProfilerTests::TestModule().

◆ SetFlags()

static proto int SetFlags ( int  flags,
bool  sessionReset = true 
)
staticprivate

Override the currently used set of EnProfilerFlags across the API.

Note
DEFAULT: EnProfilerFlags.ALL
Parameters
flagsint The combination of desired EnProfilerFlags to override the currently used set
sessionResetbool When set to false, no [SR] will trigger, regardless of situation
Returns
int The currently used set of EnProfilerFlags after the function call
// No RESET flag, [PD] will be accumulated across frames
// No RECURSIVE flag, only the curently profiled module will be sorted
// RESET flag, [PD] will be reset after sorting
// No RECURSIVE flag, only the curently profiled module will be sorted
// RESET flag, [PD] will be reset after sorting
// RECURSIVE flag, all modules will be sorted
static proto int SetFlags(int flags, bool sessionReset=true)
Override the currently used set of EnProfilerFlags across the API.

Referenced by EnProfilerTests::TestAddFlags(), EnProfilerTests::TestClearFlags(), EnProfilerTests::TestModule(), and EnProfilerTests::TestSetFlags().

◆ SetInterval()

static proto void SetInterval ( int  interval,
bool  sessionReset = true 
)
staticprivate

Set the interval for the [SD] to update.

Note
DEFAULT: 0
[DM] has the following values: {0, 5, 10, 20, 30, 50, 60, 120, 144}; When an interval not part of this list is set, [DM] will be set to "CUSTOM_INTERVAL"
Does not affect the gathering of [PD], this will happen continuously as the profiling is enabled
This also delays the [SR] caused by EnProfilerFlags.RESET
Parameters
intervalint Amount of frames to wait before [SD] is updated
sessionResetbool When set to false, no [SR] will trigger, regardless of situation
// This will make it so that [SD] is updated every 60 frames

◆ SetModule()

static proto void SetModule ( EnProfilerModule  module,
bool  sessionReset = true 
)
staticprivate

Set the module to be profiled.

Note
DEFAULT: EnProfilerModule.CORE
When session reset is enabled, it will only reset the module which it is currently being set to, previous module data will be untouched
Parameters
moduleEnProfilerModule The module to profile
sessionResetbool When set to false, no [SR] will trigger, regardless of situation

Referenced by EnProfilerTests::TestModule().

◆ SetTimeResolution()

static proto void SetTimeResolution ( int  resolution)
staticprivate

Set the resolution of the fetched Time data.

Note
DEFAULT: 100000
[DM] has the following values: {100000, 1000000, 1, 10, 100, 1000, 10000}; These are the only values available, otherwise it will round up to one in the list
Does not affect any data itself, only the fetching and displaying of it (therefore, no [SR] is ever triggered by this method)
Parameters
resolutionint The nth resolution of a second
// Have all time being reported in 1 second
// Have all time being reported in 1000th of a second (ms)
static proto void SetTimeResolution(int resolution)
Set the resolution of the fetched Time data.

Referenced by EnProfilerTests::TestClassTimeData(), EnProfilerTests::TestFuncTimeData(), and EnProfilerTests::TestModule().

◆ SortData()

static proto void SortData ( )
staticprivate

The internal sorting that happens at the end of the frame (so it is NOT necessary to call this manually) to supply Get...Per... functions.

Note
This will clear the previous [SD] and sort the [PD] currently available at this moment
Flags apply to this
Warning
Keep in mind that EnProfilerFlags.RESET will clear all [PD] after this is called
// Sorting all the currently available [PD], populating [SD]
// If flag EnProfilerFlags.RESET is enabled, then this will return 0 now even if it has been called, as [PD] has been cleared
// This goes for any Get...Of... function (Except for [CI], the counter persists)
static proto void SortData()
The internal sorting that happens at the end of the frame (so it is NOT necessary to call this manual...

Referenced by EnProfilerTests::TestModule().