4 bool m_bWasProfilerEnabled;
39 bool currentlyEnabled =
EnProfiler.IsEnabledP();
54 bool currentlyEnabled =
EnProfiler.IsEnabledC();
99 if (!
Assert(bogusFlags == 0))
107 if (!
Assert(bogusFlags == 0))
195 string nameOfCurrentModule =
Type().GetModule();
196 if (!
Assert(nameOfCurrentModule !=
""))
208 if (!
Assert(currentModule == eptModule))
219 EnProfiler.SetModule(currentlyProfiledModule);
225 bool wasEnabled =
EnProfiler.RequestImmediateData();
232 int resolution =
EnProfiler.GetTimeResolution();
236 float previousTime =
EnProfiler.GetTimeOfFunc(
"Sleep",
Type(),
true);
237 float timeSlept = Sleep(0.3);
239 float diff = postTime - previousTime - timeSlept;
245 if (!
Assert(postTime > 0))
252 EnProfiler.SetModule(currentlyProfiledModule);
257 if (!
Assert(diff < 0.00001))
264 EnProfiler.SetModule(currentlyProfiledModule);
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"))
298 EnProfiler.SetModule(currentlyProfiledModule);
307 int classCount = timePerClass.Count();
308 for (
int k = 0; k < classCount; ++k)
310 typename type = timePerClass[k].param2;
319 EnProfiler.SetModule(currentlyProfiledModule);
325 if (!
Assert(classModule == eptModule))
332 EnProfiler.SetModule(currentlyProfiledModule);
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")
371 EnProfiler.SetModule(currentlyProfiledModule);
376 return BTFR(success && found);
384 int resolution =
EnProfiler.GetTimeResolution();
385 bool wasEnabled =
EnProfiler.RequestImmediateData();
391 EPTHelperClass clss =
new EPTHelperClass();
394 float previousTime =
EnProfiler.GetTimeOfClass(clss.Type(),
true);
395 float timeStressed = clss.DoEverything();
396 float postTime =
EnProfiler.GetTimeOfClass(clss.Type(),
true);
397 float postTimeStatic =
EnProfiler.GetTimeOfClass(StaticGetType(EPTHelperClass),
true);
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;
436 bool wasEnabled =
EnProfiler.RequestImmediateData();
439 int previousAlloc =
EnProfiler.GetAllocationsOfClass(StaticGetType(EPTHelperClass),
true);
440 int previousInstances =
EnProfiler.GetInstancesOfClass(StaticGetType(EPTHelperClass),
true);
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];
453 int postAlloc =
EnProfiler.GetAllocationsOfClass(StaticGetType(EPTHelperClass),
true);
454 int postInstances =
EnProfiler.GetInstancesOfClass(StaticGetType(EPTHelperClass),
true);
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))
484 int resolution =
EnProfiler.GetTimeResolution();
485 bool wasEnabled =
EnProfiler.RequestImmediateData();
491 float previousTime =
EnProfiler.GetTimeOfFunc(
"StringFormat",
Type(),
true);
492 float timeStressed = StringFormat();
493 float postTime =
EnProfiler.GetTimeOfFunc(
"StringFormat",
Type(),
true);
494 float timeProfiled = postTime - previousTime;
495 float diff =
Math.AbsFloat(timeProfiled - timeStressed);
497 float previousTime2 =
EnProfiler.GetTimeOfFunc(
"StringConcat",
Type(),
true);
498 float timeStressed2 = StringConcat();
499 float postTime2 =
EnProfiler.GetTimeOfFunc(
"StringConcat",
Type(),
true);
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))
547 bool wasEnabled =
EnProfiler.RequestImmediateData();
552 int previousCountCF =
EnProfiler.GetCountOfFunc(
"TestFuncCountDataHelper",
Type(),
true);
553 GetGame().GameScript.CallFunction(
this,
"TestFuncCountDataHelper",
null, 0);
554 int postCountCF =
EnProfiler.GetCountOfFunc(
"TestFuncCountDataHelper",
Type(),
true);
556 int callCountCF = postCountCF - previousCountCF;
559 int previousCountCFP =
EnProfiler.GetCountOfFunc(
"TestFuncCountDataHelper",
Type(),
true);
560 GetGame().GameScript.CallFunctionParams(
this,
"TestFuncCountDataHelper",
null,
null);
561 int postCountCFP =
EnProfiler.GetCountOfFunc(
"TestFuncCountDataHelper",
Type(),
true);
563 int callCountCFP = postCountCFP - previousCountCFP;
566 int previousCountRG =
EnProfiler.GetCountOfFunc(
"TestFuncCountDataHelper",
Type(),
true);
567 TestFuncCountDataHelper();
568 int postCountRG =
EnProfiler.GetCountOfFunc(
"TestFuncCountDataHelper",
Type(),
true);
570 int callCountRG = postCountRG - previousCountRG;
573 int previousCountC =
EnProfiler.GetCountOfFunc(
"TestFuncCountDataHelper",
Type(),
true);
574 GetGame().GameScript.Call(
this,
"TestFuncCountDataHelper", 0);
575 int postCountC =
EnProfiler.GetCountOfFunc(
"TestFuncCountDataHelper",
Type(),
true);
577 int callCountC = postCountC - previousCountC;
580 int callCountNon =
EnProfiler.GetCountOfFunc(
"Non Existing Method",
Type(),
true);
583 int previousCountS =
EnProfiler.GetCountOfFunc(
"TestFuncCountDataHelperStatic",
Type(),
true);
584 TestFuncCountDataHelperStatic();
585 int postCountS =
EnProfiler.GetCountOfFunc(
"TestFuncCountDataHelperStatic",
Type(),
true);
587 int callCountS = postCountS - previousCountS;
590 int previousCountG =
EnProfiler.GetCountOfFuncG(
"GetDayZGame",
true);
592 int postCountG =
EnProfiler.GetCountOfFuncG(
"GetDayZGame",
true);
594 int callCountG = postCountG - previousCountG;
599 int callCountGP =
EnProfiler.GetCountOfFuncG(
"ErrorEx",
true);
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))
707 float Sleep(
float timeS)
709 float startTime =
GetGame().GetTickTime();
710 while (
GetGame().GetTickTime() - startTime < timeS)
715 return GetGame().GetTickTime() - startTime;
722 float startTime =
GetGame().GetTickTime();
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");
729 return GetGame().GetTickTime() - startTime;
736 float startTime =
GetGame().GetTickTime();
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";
743 return GetGame().GetTickTime() - startTime;
748 void TestFuncCountDataHelper()
755 static void TestFuncCountDataHelperStatic()
765 float startTime =
GetGame().GetTickTime();
766 while (
GetGame().GetTickTime() - startTime < timeS)
771 return GetGame().GetTickTime() - startTime;
775 float startTime =
GetGame().GetTickTime();
776 while (
GetGame().GetTickTime() - startTime < timeS)
781 return GetGame().GetTickTime() - startTime;
786 float startTime =
GetGame().GetTickTime();
791 return GetGame().GetTickTime() - startTime;