99 if (!
Assert(bogusFlags == 0))
107 if (!
Assert(bogusFlags == 0))
195 string nameOfCurrentModule =
Type().GetModule();
196 if (!
Assert(nameOfCurrentModule !=
""))
208 if (!
Assert(currentModule == eptModule))
237 float timeSlept =
Sleep(0.3);
239 float diff = postTime - previousTime - timeSlept;
245 if (!
Assert(postTime > 0))
257 if (!
Assert(diff < 0.00001))
273 for (
int i = 0; i < 1000; ++i)
283 Debug.
TFLog(
"Game fncs:",
this,
"TestModule");
285 int funcCount = timePerFunc.Count();
286 for (
int j = 0; j < funcCount; ++j)
289 Debug.
TFLog(
string.Format(
" time: %1 | fnc: %2", tfp.param1, tfp.param2),
this,
"TestModule");
291 if (!
Assert(tfp.param2 !=
"EnumTools::StringToEnum"))
307 int classCount = timePerClass.Count();
308 for (
int k = 0; k < classCount; ++k)
310 typename type = timePerClass[k].param2;
325 if (!
Assert(classModule == eptModule))
346 Debug.
TFLog(
"Core fncs:",
this,
"TestModule");
348 funcCount = timePerFunc.Count();
349 for (
int l = 0; l < funcCount; ++l)
352 Debug.
TFLog(
string.Format(
" time: %1 | fnc: %2", tfpc.param1, tfpc.param2),
this,
"TestModule");
354 if (tfpc.param2 ==
"EnumTools::StringToEnum")
376 return BTFR(success && found);
391 EPTHelperClass clss =
new EPTHelperClass();
395 float timeStressed = clss.DoEverything();
398 float timeProfiled = postTime - previousTime;
399 float diff =
Math.
AbsFloat(timeProfiled - timeStressed);
401 Debug.
TFLog(
string.Format(
"Profiling result: stressed: %1 | profiled: %2 | diff: %3", timeStressed, timeProfiled, diff),
this,
"TestClassTimeData");
409 if (!
Assert(postTime > 0))
414 if (!
Assert(postTime == postTimeStatic))
419 if (!
Assert(diff < 0.001))
431 const int allocAmount = 9;
432 const int releaseAmount = 6;
433 int remainingAmount = allocAmount - releaseAmount;
443 for (
int i = 0; i < allocAmount; ++i)
445 instanceArr.Insert(
new EPTHelperClass());
448 for (
int j = 0; j < releaseAmount; ++j)
450 delete instanceArr[j];
456 int alloced = postAlloc - previousAlloc;
457 int instances = postInstances - previousInstances;
459 Debug.
TFLog(
string.Format(
"Profiling result: alloc: %1 | instances: %2", alloced, instances),
this,
"TestClassCountData");
466 if (!
Assert(alloced == allocAmount))
471 if (!
Assert(instances == remainingAmount))
494 float timeProfiled = postTime - previousTime;
495 float diff =
Math.
AbsFloat(timeProfiled - timeStressed);
500 float timeProfiled2 = postTime2 - previousTime2;
501 float diff2 =
Math.
AbsFloat(timeProfiled2 - timeStressed2);
503 Debug.
TFLog(
string.Format(
"Profiling result: StringFormat: %1 | StringConcat: %2", timeProfiled, timeProfiled2),
this,
"TestFuncTimeData");
513 if (!
Assert(postTime > 0))
518 if (!
Assert(diff < 0.001))
523 if (!
Assert(postTime2 > 0))
528 if (!
Assert(diff2 < 0.001))
534 if (!
Assert(timeProfiled < timeProfiled2))
556 int callCountCF = postCountCF - previousCountCF;
563 int callCountCFP = postCountCFP - previousCountCFP;
570 int callCountRG = postCountRG - previousCountRG;
577 int callCountC = postCountC - previousCountC;
587 int callCountS = postCountS - previousCountS;
594 int callCountG = postCountG - previousCountG;
629 if (!
Assert(callCountCF == 1))
635 if (!
Assert(callCountCFP == 1))
641 if (!
Assert(callCountRG == 1))
647 if (!
Assert(callCountC == 1))
653 if (!
Assert(callCountNon == -1))
659 if (!
Assert(callCountS == 1))
665 if (!
Assert(callCountG == 1))
671 if (!
Assert(callCountGP == 0))
677 if (!
Assert(callCountSP == 0))
683 if (!
Assert(callCountP == 0))
689 if (!
Assert(callCountPN == 0))
695 if (!
Assert(callCountSPN == 0))
710 while (
GetGame().GetTickTime() - startTime < timeS)
724 for (
int i = 0; i < 1000; ++i)
726 string example =
string.Format(
"This %1 is %2 just %3 an %4 example %5", i,
Type(),
this, startTime,
"lorem ipsum 1 2 3");
738 for (
int i = 0; i < 1000; ++i)
740 string example =
"This " + i +
" is " +
Type() +
" just " +
this +
" an " + startTime +
" example " +
"lorem ipsum 1 2 3";
766 while (
GetGame().GetTickTime() - startTime < timeS)
776 while (
GetGame().GetTickTime() - startTime < timeS)
float SleepAgain(float timeS)
EnProfilerTests TestFramework Sleep2(float timeS)
TFResult NTFR(TFR result)
bool Assert(bool condition)
void TFResult(TFR result)
void AddInitTest(string test)
TFResult BTFR(bool result)
proto native float GetTickTime()
Returns current time from start of the game.
proto owned string GetHostName()
Gets the server name. (from client)
proto native bool IsServer()
static void TFLog(string message=LOG_DEFAULT, TestFramework caller=null, string function="")
Set of methods for accessing script profiling data.
TFResult TestFuncCountData()
TFResult TestClearFlags()
void TestFuncCountDataHelper()
bool m_bWasProfilerEnabled
Remember this, so we can restore the previous state before the test!
TFResult TestTogglingImmediate()
TFResult TestClassTimeData()
static void TestFuncCountDataHelperStatic()
TFResult TestClassCountData()
TFResult TestFuncTimeData()
static proto native ErrorModuleHandler GetInstance()
Gets the EMH Instance.
The error handler itself, for managing and distributing errors to modules Manages the ErrorHandlerMod...
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
proto volatile int CallFunctionParams(Class inst, string function, out void returnVal, Class parms)
proto volatile int Call(Class inst, string function, void parm)
proto volatile int CallFunction(Class inst, string function, out void returnVal, void parm)
static proto float AbsFloat(float f)
Returns absolute value.
static proto int GetTimeResolution()
Get the currently set time resolution.
static proto EnProfilerModule GetModule()
Get the currently profiled module.
static proto void GetTimePerFunc(notnull out array< ref EnProfilerTimeFuncPair > outArr, int count=int.MAX)
Obtain [SD] for Time Per Function.
Param2< float, string > EnProfilerTimeFuncPair
static proto int GetAllocationsOfClass(typename clss, bool immediate=false)
Obtain [SD] or [PD] regarding the allocations of a specific class.
static proto float GetTimeOfClass(typename clss, bool immediate=false)
Obtain [SD] or [PD] regarding the time a specific class consumed.
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 GetFlags()
Get the currently used flags across the API.
static proto int ClearFlags(bool sessionReset=true)
Remove all flags from the currently used set of EnProfilerFlags across the API.
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 void SetTimeResolution(int resolution)
Set the resolution of the fetched Time data.
static proto void SortData()
The internal sorting that happens at the end of the frame (so it is NOT necessary to call this manual...
static proto void SetModule(EnProfilerModule module, bool sessionReset=true)
Set the module to be profiled.
static proto void ResetSession(bool fullReset=false)
Perform [SR], clearing SessionFrame, ProfiledSessionFrames, [SD] and [PD] (except for [CI])
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 int GetInstancesOfClass(typename clss, bool immediate=false)
Obtain [SD] or [PD] regarding the [CI] of a specific class.
EnProfilerFlags
Flags that influences the behaviour of the EnProfiler API, applied through ...Flags functions.
static proto void GetTimePerClass(notnull out array< ref EnProfilerTimeClassPair > outArr, int count=int.MAX)
Obtain [SD] for Time Per Class.
static proto int SetFlags(int flags, bool sessionReset=true)
Override the currently used set of EnProfilerFlags across the API.
static proto void Enable(bool enable, bool immediate=false, bool sessionReset=true)
Enable the gathering of script profiling data.
EnProfilerModule
Current base scripted modules.
static proto bool NameToModule(string moduleName, out EnProfilerModule module)
Convert string to EnProfilerModule.
static bool RequestImmediateData()
Helper method to ascertain the profiler will record [PD] right after this call.
static proto int RemoveFlags(int flags, bool sessionReset=true)
Remove flags from the currently used set of EnProfilerFlags across the API.
static proto int GetCountOfFuncG(string funct, bool immediate=false)
Obtain [SD] or [PD] regarding the amount of times a specific function was called.
static proto int AddFlags(int flags, bool sessionReset=true)
Add flags to the currently used set of EnProfilerFlags across the API.