DayZ 1.24
Loading...
Searching...
No Matches
Enforce Script profiling API

Classes

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 EnProfiler::Enable (bool enable, bool immediate=false, bool sessionReset=true)
 Enable the gathering of script profiling data.
 
static proto int EnProfiler::IsEnabled ()
 Return if script profiling is enabled.
 
static bool EnProfiler::IsEnabledD ()
 Return if script profiling is enabled through [DM].
 
static bool EnProfiler::IsEnabledP ()
 Return if script profiling is enabled through EnProfiler.
 
static bool EnProfiler::IsEnabledC ()
 Return if script profiling is actually turned on inside of the script context.
 
static proto void EnProfiler::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 EnProfiler::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 EnProfiler::SetFlags (int flags, bool sessionReset=true)
 Override the currently used set of EnProfilerFlags across the API.
 
static proto int EnProfiler::GetFlags ()
 Get the currently used flags across the API.
 
static proto bool EnProfiler::IsFlagsSet (int flags)
 Check if the flags are set.
 
static proto int EnProfiler::AddFlags (int flags, bool sessionReset=true)
 Add flags to the currently used set of EnProfilerFlags across the API.
 
static proto int EnProfiler::RemoveFlags (int flags, bool sessionReset=true)
 Remove flags from the currently used set of EnProfilerFlags across the API.
 
static proto int EnProfiler::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 EnProfiler::SetModule (EnProfilerModule module, bool sessionReset=true)
 Set the module to be profiled.
 
static proto EnProfilerModule EnProfiler::GetModule ()
 Get the currently profiled module.
 
static proto owned string EnProfiler::ModuleToName (EnProfilerModule module)
 Helper to convert EnProfilerModule to string.
 
static proto bool EnProfiler::NameToModule (string moduleName, out EnProfilerModule module)
 Convert string to EnProfilerModule.
 
static proto void EnProfiler::SetInterval (int interval, bool sessionReset=true)
 Set the interval for the [SD] to update.
 
static proto int EnProfiler::GetInterval ()
 Get the currently set interval.
 
static proto void EnProfiler::SetTimeResolution (int resolution)
 Set the resolution of the fetched Time data.
 
static proto int EnProfiler::GetTimeResolution ()
 Get the currently set time resolution.
 
static proto void EnProfiler::EnableAverage (bool enable)
 Enable/disable returning calculated averages.
 
static proto bool EnProfiler::IsAverage ()
 Check if returning of average data is enabled.
 
static proto void EnProfiler::Dump ()
 Print out [SD] to script log.
 

Frame data

Set of functions to obtain information about frame counts

static proto int EnProfiler::GetGameFrame ()
 Get the total amount of frames passed.
 
static proto int EnProfiler::GetSessionFrame ()
 Get the total amount of frames in this profiling session.
 
static proto int EnProfiler::GetTotalFrames ()
 Get the total amount of frames across all profiling session.
 
static proto int EnProfiler::GetProfiledSessionFrames ()
 Get the total amount of frames profiled in this profiling session.
 
static proto int EnProfiler::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 EnProfiler::GetTimePerClass (notnull out array< ref EnProfilerTimeClassPair > outArr, int count=int.MAX)
 Obtain [SD] for Time Per Class.
 
static proto void EnProfiler::GetAllocationsPerClass (notnull out array< ref EnProfilerCountClassPair > outArr, int count=int.MAX)
 Obtain [SD] for Allocations Per Class.
 
static proto void EnProfiler::GetInstancesPerClass (notnull out array< ref EnProfilerCountClassPair > outArr, int count=int.MAX)
 Obtain [SD] for Instances Per Class.
 
static proto void EnProfiler::GetTimePerFunc (notnull out array< ref EnProfilerTimeFuncPair > outArr, int count=int.MAX)
 Obtain [SD] for Time Per Function.
 
static proto void EnProfiler::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 EnProfiler::GetTimeOfClass (typename clss, bool immediate=false)
 Obtain [SD] or [PD] regarding the time a specific class consumed.
 
static proto int EnProfiler::GetAllocationsOfClass (typename clss, bool immediate=false)
 Obtain [SD] or [PD] regarding the allocations of a specific class.
 
static proto int EnProfiler::GetInstancesOfClass (typename clss, bool immediate=false)
 Obtain [SD] or [PD] regarding the [CI] of a specific class.
 
static proto float EnProfiler::GetTimeOfFunc (string funct, typename clss, bool immediate=false)
 Obtain [SD] or [PD] regarding the time consumed by a specific function.
 
static proto float EnProfiler::GetTimeOfFuncG (string funct, bool immediate, bool immediate=false)
 Obtain [SD] or [PD] regarding the time consumed by a specific global function.
 
static proto int EnProfiler::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 EnProfiler::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 EnProfiler::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)

Definition at line 43 of file EnProfiler.c.

44{
46 NONE,
48 DIAG,
50 SCRP,
52 SCRC,
53};
@ DIAG
Script profiling UI is enabled in WIN+ALT debug menu, when this is true, it will override SCRP.
Definition EnProfiler.c:48
@ SCRP
It has been set to being always enabled through EnProfiler (SCRipt Profiler)
Definition EnProfiler.c:50
@ NONE
No flags.
Definition EnProfiler.c:11
@ SCRC
Whether profiling is currently truly happening (SCRipt Context)
Definition EnProfiler.c:52

◆ 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.

Definition at line 8 of file EnProfiler.c.

9{
11 NONE,
13 RESET,
17 ALL
18};
@ RECURSIVE
Whether to profile child modules.
Definition EnProfiler.c:15
@ RESET
When present, will reset [PD] on sorting, otherwise will accumulate on top of it.
Definition EnProfiler.c:13
@ ALL
All flags enabled.
Definition EnProfiler.c:17

◆ 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.

Definition at line 21 of file EnProfiler.c.

22{
24 CORE,
26 GAMELIB,
28 GAME,
30 WORLD,
32 MISSION,
36 ERROR,
37};
@ ERROR
Can be returned from some methods.
Definition EnProfiler.c:36
@ WORLD
4_World
Definition EnProfiler.c:30
@ CORE
1_Core
Definition EnProfiler.c:24
@ GAMELIB
2_GameLib
Definition EnProfiler.c:26
@ MISSION_CUSTOM
init.c
Definition EnProfiler.c:34
@ GAME
3_Game
Definition EnProfiler.c:28
@ MISSION
5_Mission
Definition EnProfiler.c:32

Function Documentation

◆ AddFlags()

static proto int EnProfiler::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
EnProfilerFlags
Flags that influences the behaviour of the EnProfiler API, applied through ...Flags functions.
Definition EnProfiler.c:9
static proto int AddFlags(int flags, bool sessionReset=true)
Add flags to the currently used set of EnProfilerFlags across the API.

Referenced by EnProfilerTests::TestAddFlags().

◆ ClearFlags()

static proto int EnProfiler::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 EnProfiler::Dump ( )
staticprivate

Print out [SD] to script log.

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

◆ Enable()

static proto void EnProfiler::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 EnProfiler::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 EnProfiler::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
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 EnProfiler::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
static proto void GetAllocationsPerClass(notnull out array< ref EnProfilerCountClassPair > outArr, int count=int.MAX)
Obtain [SD] for Allocations Per Class.

◆ GetCountOfFunc()

static proto int EnProfiler::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);
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 EnProfiler::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
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 EnProfiler::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
static proto void GetCountPerFunc(notnull out array< ref EnProfilerCountFuncPair > outArr, int count=int.MAX)
Obtain [SD] for Count Per Function.

◆ GetFlags()

static proto int EnProfiler::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 EnProfiler::GetGameFrame ( )
staticprivate

Get the total amount of frames passed.

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

◆ GetInstancesOfClass()

static proto int EnProfiler::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
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 EnProfiler::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
static proto void GetInstancesPerClass(notnull out array< ref EnProfilerCountClassPair > outArr, int count=int.MAX)
Obtain [SD] for Instances Per Class.

◆ GetInterval()

static proto int EnProfiler::GetInterval ( )
staticprivate

Get the currently set interval.

Returns
int The currently set interval
static proto int GetInterval()
Get the currently set interval.

◆ GetModule()

static proto EnProfilerModule EnProfiler::GetModule ( )
staticprivate

Get the currently profiled module.

Returns
EnProfilerModule The currently profiled module
EnProfilerModule module = EnProfiler.GetModule();
EnProfilerModule
Current base scripted modules.
Definition EnProfiler.c:22

Referenced by EnProfilerTests::TestModule().

◆ GetProfiledFrames()

static proto int EnProfiler::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
static proto int GetProfiledFrames()
Get the total amount of frames profiled across all profiling session.

◆ GetProfiledSessionFrames()

static proto int EnProfiler::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
static proto int GetProfiledSessionFrames()
Get the total amount of frames profiled in this profiling session.

◆ GetSessionFrame()

static proto int EnProfiler::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
static proto int GetSessionFrame()
Get the total amount of frames in this profiling session.

◆ GetTimeOfClass()

static proto float EnProfiler::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
// 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 EnProfiler::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 EnProfiler::GetTimeOfFuncG ( string funct,
bool immediate,
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, bool immediate=false)
Obtain [SD] or [PD] regarding the time consumed by a specific global function.

◆ GetTimePerClass()

static proto void EnProfiler::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
// In this example the array will be filled with all classes sorted by time
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 EnProfiler::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
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 EnProfiler::GetTimeResolution ( )
staticprivate

Get the currently set time resolution.

Returns
int The currently set resolution
static proto int GetTimeResolution()
Get the currently set time resolution.

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

◆ GetTotalFrames()

static proto int EnProfiler::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
static proto int GetTotalFrames()
Get the total amount of frames across all profiling session.

◆ IsAverage()

static proto bool EnProfiler::IsAverage ( )
staticprivate

Check if returning of average data is enabled.

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

◆ IsEnabled()

static proto int EnProfiler::IsEnabled ( )
staticprivate

Return if script profiling is enabled.

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

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

◆ IsEnabledC()

static bool EnProfiler::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
static bool IsEnabledC()
Return if script profiling is actually turned on inside of the script context.
Definition EnProfiler.c:152

Definition at line 152 of file EnProfiler.c.

153 {
154 return (IsEnabled() & EnProfilerEnabledFlags.SCRC);
155 }
EnProfilerEnabledFlags
There are 3 states which can be toggled that governs whether script profiling is enabled or not.
Definition EnProfiler.c:44

References EnProfiler::IsEnabled().

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

◆ IsEnabledD()

static bool EnProfiler::IsEnabledD ( )
inlinestaticprivate

Return if script profiling is enabled through [DM].

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

Definition at line 124 of file EnProfiler.c.

125 {
126 return (IsEnabled() & EnProfilerEnabledFlags.DIAG);
127 }

References EnProfiler::IsEnabled().

◆ IsEnabledP()

static bool EnProfiler::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
static bool IsEnabledP()
Return if script profiling is enabled through EnProfiler.
Definition EnProfiler.c:138

Definition at line 138 of file EnProfiler.c.

139 {
140 return (IsEnabled() & EnProfilerEnabledFlags.SCRP);
141 }

References EnProfiler::IsEnabled().

Referenced by EnProfilerTests::TestToggling().

◆ IsFlagsSet()

static proto bool EnProfiler::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 EnProfiler::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
static proto owned string ModuleToName(EnProfilerModule module)
Helper to convert EnProfilerModule to string.

◆ NameToModule()

static proto bool EnProfiler::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
{
}
else
{
ErrorEx(string.Format("Could not find EnProfilerModule: %1", nameOfCurrentModule));
}
string Type
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 EnProfiler::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 EnProfiler::RequestImmediateData ( )
inlinestaticprivate

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

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

Definition at line 735 of file EnProfiler.c.

736 {
737 // I only care if it is actually profiling right now, so C
738 bool wasEnabled = IsEnabledC();
739
740 if (!wasEnabled)
741 {
742 // I want the data, and I want it now, so immediate
743 Enable(true, true);
744 }
745
746 return wasEnabled;
747 }

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

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

◆ ResetSession()

static proto void EnProfiler::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 EnProfiler::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 EnProfiler::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 EnProfiler::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 EnProfiler::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 EnProfiler::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().