123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793 |
- class EnProfilerTests : TestFramework
- {
- //! Remember this, so we can restore the previous state before the test!
- bool m_bWasProfilerEnabled;
-
- //---------------------------------------------------------------------------
- // Ctor - Decides the tests to run
- //---------------------------------------------------------------------------
- void EnProfilerTests()
- {
- m_bWasProfilerEnabled = EnProfiler.IsEnabledC();
-
- AddInitTest("TestToggling");
- AddInitTest("TestTogglingImmediate");
- AddInitTest("TestSetFlags");
- AddInitTest("TestClearFlags");
- AddInitTest("TestAddFlags");
- AddInitTest("TestModule");
- AddInitTest("TestClassTimeData");
- AddInitTest("TestClassCountData");
- AddInitTest("TestFuncTimeData");
- AddInitTest("TestFuncCountData");
- }
-
- //---------------------------------------------------------------------------
- // Dtor
- //---------------------------------------------------------------------------
- void ~EnProfilerTests()
- {
- EnProfiler.Enable(m_bWasProfilerEnabled, true);
- }
-
- //---------------------------------------------------------------------------
- // Tests
- //---------------------------------------------------------------------------
- // Test toggling state
- TFResult TestToggling()
- {
- bool currentlyEnabled = EnProfiler.IsEnabledP();
- EnProfiler.Enable(!currentlyEnabled);
- if (Assert(currentlyEnabled != EnProfiler.IsEnabledP()))
- {
- EnProfiler.Enable(currentlyEnabled);
- return BTFR(Assert(currentlyEnabled == EnProfiler.IsEnabledP()));
- }
-
- return NTFR(TFR.FAIL);
- }
-
- //---------------------------------------------------------------------------
- // Test toggling immediate state
- TFResult TestTogglingImmediate()
- {
- bool currentlyEnabled = EnProfiler.IsEnabledC();
- EnProfiler.Enable(!currentlyEnabled, true);
- if (Assert(currentlyEnabled != EnProfiler.IsEnabledC()))
- {
- EnProfiler.Enable(currentlyEnabled, true);
- return BTFR(Assert(currentlyEnabled == EnProfiler.IsEnabledC()));
- }
-
- return NTFR(TFR.FAIL);
- }
-
- //---------------------------------------------------------------------------
- // Test SetFlags/GetFlags
- TFResult TestSetFlags()
- {
- int currentFlags = EnProfiler.GetFlags();
-
- for (int i = 0; i < EnumTools.GetEnumSize(EnProfilerFlags); ++i)
- {
- int flags = EnumTools.GetEnumValue(EnProfilerFlags, i);
- EnProfiler.SetFlags(flags);
-
- if (!Assert(EnProfiler.GetFlags() == flags))
- {
- EnProfiler.SetFlags(currentFlags);
- return NTFR(TFR.FAIL);
- }
-
- for (int j = 0; j < EnumTools.GetEnumSize(EnProfilerFlags); ++j)
- {
- flags |= EnumTools.GetEnumValue(EnProfilerFlags, j);
- EnProfiler.SetFlags(flags);
-
- if (!Assert(EnProfiler.GetFlags() == flags))
- {
- EnProfiler.SetFlags(currentFlags);
- return NTFR(TFR.FAIL);
- }
- }
- }
-
- // Let's test some bogus
- EnProfiler.SetFlags(-333);
- int bogusFlags = EnProfiler.GetFlags();
- bogusFlags &= ~EnProfilerFlags.ALL;
- if (!Assert(bogusFlags == 0))
- {
- EnProfiler.SetFlags(currentFlags);
- return NTFR(TFR.FAIL);
- }
-
- bogusFlags = EnProfiler.SetFlags(6003);
- bogusFlags &= ~EnProfilerFlags.ALL;
- if (!Assert(bogusFlags == 0))
- {
- EnProfiler.SetFlags(currentFlags);
- return NTFR(TFR.FAIL);
- }
-
- // Reset
- EnProfiler.SetFlags(currentFlags);
- return NTFR(TFR.SUCCESS);
- }
-
- //---------------------------------------------------------------------------
- // Test removing of flags
- TFResult TestClearFlags()
- {
- int currentFlags = EnProfiler.GetFlags();
-
- EnProfiler.SetFlags(EnProfilerFlags.RECURSIVE);
-
- if (!Assert(EnProfiler.RemoveFlags(EnProfilerFlags.RECURSIVE) == EnProfilerFlags.NONE))
- {
- EnProfiler.SetFlags(currentFlags);
- return NTFR(TFR.FAIL);
- }
-
- EnProfiler.SetFlags(EnProfilerFlags.RECURSIVE | EnProfilerFlags.RESET);
- EnProfiler.RemoveFlags(EnProfilerFlags.RECURSIVE | EnProfilerFlags.RESET);
-
- if (!Assert(EnProfiler.GetFlags() == EnProfilerFlags.NONE))
- {
- EnProfiler.SetFlags(currentFlags);
- return NTFR(TFR.FAIL);
- }
-
- EnProfiler.SetFlags(EnProfilerFlags.RECURSIVE | EnProfilerFlags.RESET);
- EnProfiler.ClearFlags();
-
- if (!Assert(EnProfiler.GetFlags() == EnProfilerFlags.NONE))
- {
- EnProfiler.SetFlags(currentFlags);
- return NTFR(TFR.FAIL);
- }
-
- // Reset
- EnProfiler.SetFlags(currentFlags);
- return NTFR(TFR.SUCCESS);
- }
-
- //---------------------------------------------------------------------------
- // Test adding of flags
- TFResult TestAddFlags()
- {
- int currentFlags = EnProfiler.GetFlags();
-
- EnProfiler.ClearFlags();
-
- // Return should match resulting flags
- if (!Assert(EnProfiler.AddFlags(EnProfilerFlags.RESET) == EnProfiler.GetFlags()))
- {
- EnProfiler.SetFlags(currentFlags);
- return NTFR(TFR.FAIL);
- }
-
- if (!Assert(EnProfiler.GetFlags() == EnProfilerFlags.RESET))
- {
- EnProfiler.SetFlags(currentFlags);
- return NTFR(TFR.FAIL);
- }
-
- if (!Assert(EnProfiler.AddFlags(EnProfilerFlags.RECURSIVE) == (EnProfilerFlags.RESET | EnProfilerFlags.RECURSIVE)))
- {
- EnProfiler.SetFlags(currentFlags);
- return NTFR(TFR.FAIL);
- }
-
- // Reset
- EnProfiler.SetFlags(currentFlags);
- return NTFR(TFR.SUCCESS);
- }
-
- //---------------------------------------------------------------------------
- // Test module
- TFResult TestModule()
- {
- // File lives in Game, use it while testing
- const EnProfilerModule eptModule = EnProfilerModule.GAME;
-
- // This was added at the same time as this API, so check if it works as well
- string nameOfCurrentModule = Type().GetModule();
- if (!Assert(nameOfCurrentModule != ""))
- {
- return NTFR(TFR.FAIL);
- }
-
- // We know we are in Game, so use it as a test
- EnProfilerModule currentModule;
- if (!Assert(EnProfiler.NameToModule(nameOfCurrentModule, currentModule)))
- {
- return NTFR(TFR.FAIL);
- }
-
- if (!Assert(currentModule == eptModule))
- {
- return NTFR(TFR.FAIL);
- }
-
- // Test if setting and getting works
- EnProfilerModule currentlyProfiledModule = EnProfiler.GetModule();
- EnProfiler.SetModule(eptModule);
-
- if (!Assert(EnProfiler.GetModule() == eptModule))
- {
- EnProfiler.SetModule(currentlyProfiledModule);
- return NTFR(TFR.FAIL);
- }
-
- // Data to restore
- int currentFlags = EnProfiler.GetFlags();
- bool wasEnabled = EnProfiler.RequestImmediateData();
-
- // Make sure we are only profiling Game and that the data is clean
- // Only valid for the Get...Per... methods, as they need to be sorted
- EnProfiler.RemoveFlags(EnProfilerFlags.RECURSIVE);
-
- // GetTickTime() returns in seconds, so gather the results in seconds too
- int resolution = EnProfiler.GetTimeResolution();
- EnProfiler.SetTimeResolution(1);
-
- // Time to sleeb
- float previousTime = EnProfiler.GetTimeOfFunc("Sleep", Type(), true);
- float timeSlept = Sleep(0.3);
- float postTime = EnProfiler.GetTimeOfFunc("Sleep", Type(), true);
- float diff = postTime - previousTime - timeSlept;
-
- // Restore
- EnProfiler.SetTimeResolution(resolution);
-
- // We called the function, so it must have some time
- if (!Assert(postTime > 0))
- {
- EnProfiler.SetFlags(currentFlags);
-
- if (!wasEnabled)
- EnProfiler.Enable(false, true);
-
- EnProfiler.SetModule(currentlyProfiledModule);
-
- return NTFR(TFR.FAIL);
- }
-
- if (!Assert(diff < 0.00001))
- {
- EnProfiler.SetFlags(currentFlags);
-
- if (!wasEnabled)
- EnProfiler.Enable(false, true);
-
- EnProfiler.SetModule(currentlyProfiledModule);
-
- return NTFR(TFR.FAIL);
- }
-
- // Clean the session
- EnProfiler.ResetSession(true);
-
- // Something from a different module should not get sorted, so just fire something from a different module
- for (int i = 0; i < 1000; ++i)
- {
- EnumTools.StringToEnum(EnProfilerModule, "MISSION_CUSTOM");
- }
-
- // Sort and gather the data and validate if it is correct
- EnProfiler.SortData();
- array<ref EnProfilerTimeFuncPair> timePerFunc = {};
- EnProfiler.GetTimePerFunc(timePerFunc);
-
- Debug.TFLog("Game fncs:", this, "TestModule");
-
- int funcCount = timePerFunc.Count();
- for (int j = 0; j < funcCount; ++j)
- {
- EnProfilerTimeFuncPair tfp = timePerFunc[j];
- Debug.TFLog(string.Format(" time: %1 | fnc: %2", tfp.param1, tfp.param2), this, "TestModule");
- // We are currently profiling Game, so this Core function shouldn't be present
- if (!Assert(tfp.param2 != "EnumTools::StringToEnum"))
- {
- EnProfiler.SetFlags(currentFlags);
-
- if (!wasEnabled)
- EnProfiler.Enable(false, true);
-
- EnProfiler.SetModule(currentlyProfiledModule);
-
- return NTFR(TFR.FAIL);
- }
- }
-
- array<ref EnProfilerTimeClassPair> timePerClass = {};
- EnProfiler.GetTimePerClass(timePerClass);
-
- int classCount = timePerClass.Count();
- for (int k = 0; k < classCount; ++k)
- {
- typename type = timePerClass[k].param2;
- EnProfilerModule classModule;
- if (!Assert(EnProfiler.NameToModule(type.GetModule(), classModule)))
- {
- EnProfiler.SetFlags(currentFlags);
-
- if (!wasEnabled)
- EnProfiler.Enable(false, true);
-
- EnProfiler.SetModule(currentlyProfiledModule);
-
- return NTFR(TFR.FAIL);
- }
-
- // Only classes from Game should be present
- if (!Assert(classModule == eptModule))
- {
- EnProfiler.SetFlags(currentFlags);
-
- if (!wasEnabled)
- EnProfiler.Enable(false, true);
-
- EnProfiler.SetModule(currentlyProfiledModule);
-
- return NTFR(TFR.FAIL);
- }
- }
-
- // Now let's check if we can gather the data of what we called earlier by switching the profiled module without resetting the session
- EnProfiler.SetModule(EnProfilerModule.CORE, false);
- EnProfiler.SortData();
- timePerFunc.Clear(); // Let's reuse the array, but the Get...Per... methods only appends to the array, clearing is our responsibility
- EnProfiler.GetTimePerFunc(timePerFunc);
-
- bool found = false;
-
- Debug.TFLog("Core fncs:", this, "TestModule");
-
- funcCount = timePerFunc.Count();
- for (int l = 0; l < funcCount; ++l)
- {
- EnProfilerTimeFuncPair tfpc = timePerFunc[l];
- Debug.TFLog(string.Format(" time: %1 | fnc: %2", tfpc.param1, tfpc.param2), this, "TestModule");
- // We are currently profiling Core, so this Core function should be present
- if (tfpc.param2 == "EnumTools::StringToEnum")
- {
- found = true;
- break;
- }
- }
-
- Assert(found);
-
- // Test some bogus
- EnProfilerModule mod = EnProfiler.GetModule();
- EnProfiler.SetModule(-333);
- bool success = Assert(EnProfiler.GetModule() == mod);
- EnProfiler.SetModule(6003);
- success &= Assert(EnProfiler.GetModule() == mod);
-
- EnProfiler.SetFlags(currentFlags);
- EnProfiler.SetModule(currentlyProfiledModule);
-
- if (!wasEnabled)
- EnProfiler.Enable(false, true);
-
- return BTFR(success && found);
- }
-
- //---------------------------------------------------------------------------
- // Test to see if class time data is correct
- TFResult TestClassTimeData()
- {
- // We should restore this when done
- int resolution = EnProfiler.GetTimeResolution();
- bool wasEnabled = EnProfiler.RequestImmediateData();
-
- // GetTickTime() returns in seconds, so gather the results in seconds too
- EnProfiler.SetTimeResolution(1);
-
- // Create the classes
- EPTHelperClass clss = new EPTHelperClass();
-
- // Time to stress
- float previousTime = EnProfiler.GetTimeOfClass(clss.Type(), true);
- float timeStressed = clss.DoEverything();
- float postTime = EnProfiler.GetTimeOfClass(clss.Type(), true);
- float postTimeStatic = EnProfiler.GetTimeOfClass(StaticGetType(EPTHelperClass), true);
- float timeProfiled = postTime - previousTime;
- float diff = Math.AbsFloat(timeProfiled - timeStressed);
-
- Debug.TFLog(string.Format("Profiling result: stressed: %1 | profiled: %2 | diff: %3", timeStressed, timeProfiled, diff), this, "TestClassTimeData");
-
- // Restore
- EnProfiler.SetTimeResolution(resolution);
- if (!wasEnabled)
- EnProfiler.Enable(false, true);
-
- // We called the function, so it must have some time
- if (!Assert(postTime > 0))
- {
- return NTFR(TFR.FAIL);
- }
-
- if (!Assert(postTime == postTimeStatic))
- {
- return NTFR(TFR.FAIL);
- }
-
- if (!Assert(diff < 0.001))
- {
- return NTFR(TFR.FAIL);
- }
-
- return NTFR(TFR.SUCCESS);
- }
-
- //---------------------------------------------------------------------------
- // Test to see if class count data is correct
- TFResult TestClassCountData()
- {
- const int allocAmount = 9;
- const int releaseAmount = 6;
- int remainingAmount = allocAmount - releaseAmount;
-
- // We should restore this when done
- bool wasEnabled = EnProfiler.RequestImmediateData();
-
- // Time to test
- int previousAlloc = EnProfiler.GetAllocationsOfClass(StaticGetType(EPTHelperClass), true);
- int previousInstances = EnProfiler.GetInstancesOfClass(StaticGetType(EPTHelperClass), true);
- array<ref EPTHelperClass> instanceArr = {};
- for (int i = 0; i < allocAmount; ++i)
- {
- instanceArr.Insert(new EPTHelperClass());
- }
-
- for (int j = 0; j < releaseAmount; ++j)
- {
- delete instanceArr[j];
- }
-
- int postAlloc = EnProfiler.GetAllocationsOfClass(StaticGetType(EPTHelperClass), true);
- int postInstances = EnProfiler.GetInstancesOfClass(StaticGetType(EPTHelperClass), true);
-
- int alloced = postAlloc - previousAlloc;
- int instances = postInstances - previousInstances;
-
- Debug.TFLog(string.Format("Profiling result: alloc: %1 | instances: %2", alloced, instances), this, "TestClassCountData");
-
- // Restore
- if (!wasEnabled)
- EnProfiler.Enable(false, true);
-
- // Time to check
- if (!Assert(alloced == allocAmount))
- {
- return NTFR(TFR.FAIL);
- }
-
- if (!Assert(instances == remainingAmount))
- {
- return NTFR(TFR.FAIL);
- }
-
- return NTFR(TFR.SUCCESS);
- }
-
- //---------------------------------------------------------------------------
- // Test to see if func time data is correct
- TFResult TestFuncTimeData()
- {
- // We should restore this when done
- int resolution = EnProfiler.GetTimeResolution();
- bool wasEnabled = EnProfiler.RequestImmediateData();
-
- // GetTickTime() returns in seconds, so gather the results in seconds too
- EnProfiler.SetTimeResolution(1);
-
- // Time to stress
- float previousTime = EnProfiler.GetTimeOfFunc("StringFormat", Type(), true);
- float timeStressed = StringFormat();
- float postTime = EnProfiler.GetTimeOfFunc("StringFormat", Type(), true);
- float timeProfiled = postTime - previousTime;
- float diff = Math.AbsFloat(timeProfiled - timeStressed);
-
- float previousTime2 = EnProfiler.GetTimeOfFunc("StringConcat", Type(), true);
- float timeStressed2 = StringConcat();
- float postTime2 = EnProfiler.GetTimeOfFunc("StringConcat", Type(), true);
- float timeProfiled2 = postTime2 - previousTime2;
- float diff2 = Math.AbsFloat(timeProfiled2 - timeStressed2);
-
- Debug.TFLog(string.Format("Profiling result: StringFormat: %1 | StringConcat: %2", timeProfiled, timeProfiled2), this, "TestFuncTimeData");
-
- // Restore
- EnProfiler.SetTimeResolution(resolution);
- if (!wasEnabled)
- {
- EnProfiler.Enable(false, true);
- }
-
- // We called the function, so it must have some time
- if (!Assert(postTime > 0))
- {
- return NTFR(TFR.FAIL);
- }
-
- if (!Assert(diff < 0.001))
- {
- return NTFR(TFR.FAIL);
- }
-
- if (!Assert(postTime2 > 0))
- {
- return NTFR(TFR.FAIL);
- }
-
- if (!Assert(diff2 < 0.001))
- {
- return NTFR(TFR.FAIL);
- }
-
- // I know that string.Format is faster than additive concatenation
- if (!Assert(timeProfiled < timeProfiled2))
- {
- return NTFR(TFR.FAIL);
- }
-
- return NTFR(TFR.SUCCESS);
- }
-
- //---------------------------------------------------------------------------
- // Test to see if func count data is correct
- TFResult TestFuncCountData()
- {
- // We should restore this when done
- bool wasEnabled = EnProfiler.RequestImmediateData();
-
- // Time to count
-
- // - CallFunction
- int previousCountCF = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
- GetGame().GameScript.CallFunction(this, "TestFuncCountDataHelper", null, 0);
- int postCountCF = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
-
- int callCountCF = postCountCF - previousCountCF;
-
- // - CallFunctionParams
- int previousCountCFP = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
- GetGame().GameScript.CallFunctionParams(this, "TestFuncCountDataHelper", null, null);
- int postCountCFP = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
-
- int callCountCFP = postCountCFP - previousCountCFP;
-
- // - Regular call
- int previousCountRG = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
- TestFuncCountDataHelper();
- int postCountRG = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
-
- int callCountRG = postCountRG - previousCountRG;
-
- // - Call
- int previousCountC = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
- GetGame().GameScript.Call(this, "TestFuncCountDataHelper", 0);
- int postCountC = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
-
- int callCountC = postCountC - previousCountC;
-
- // - Garbage
- int callCountNon = EnProfiler.GetCountOfFunc("Non Existing Method", Type(), true);
-
- // - Static
- int previousCountS = EnProfiler.GetCountOfFunc("TestFuncCountDataHelperStatic", Type(), true);
- TestFuncCountDataHelperStatic();
- int postCountS = EnProfiler.GetCountOfFunc("TestFuncCountDataHelperStatic", Type(), true);
-
- int callCountS = postCountS - previousCountS;
-
- // - Global
- int previousCountG = EnProfiler.GetCountOfFuncG("GetDayZGame", true);
- GetDayZGame();
- int postCountG = EnProfiler.GetCountOfFuncG("GetDayZGame", true);
-
- int callCountG = postCountG - previousCountG;
-
- // - Global proto
- // Not tracked, so don't need to compare before and after, should always be 0
- ErrorEx("Testing global proto call", ErrorExSeverity.INFO);
- int callCountGP = EnProfiler.GetCountOfFuncG("ErrorEx", true);
-
- // - Static proto
- // Not tracked, so don't need to compare before and after, should always be 0
- int callCountSP = EnProfiler.GetCountOfFunc("GetCountOfFunc", StaticGetType(EnProfiler), true);
-
- // - proto
- // Not tracked, so don't need to compare before and after, should always be 0
- GetGame().GetHostName();
- int callCountP = EnProfiler.GetCountOfFunc("GetHostName", GetGame().Type(), true);
-
- // - proto native
- // Not tracked, so don't need to compare before and after, should always be 0
- GetGame().IsServer();
- int callCountPN = EnProfiler.GetCountOfFunc("IsServer", GetGame().Type(), true);
-
- // - static proto native
- // Not tracked, so don't need to compare before and after, should always be 0
- ErrorModuleHandler.GetInstance();
- int callCountSPN = EnProfiler.GetCountOfFunc("GetInstance", StaticGetType(ErrorModuleHandler), true);
-
- // Restore
- if (!wasEnabled)
- {
- EnProfiler.Enable(false, true);
- }
-
- // Do the checks
-
- // - CallFunction
- if (!Assert(callCountCF == 1))
- {
- return NTFR(TFR.FAIL);
- }
-
- // - CallFunctionParams
- if (!Assert(callCountCFP == 1))
- {
- return NTFR(TFR.FAIL);
- }
-
- // - Regular call
- if (!Assert(callCountRG == 1))
- {
- return NTFR(TFR.FAIL);
- }
-
- // - Call
- if (!Assert(callCountC == 1))
- {
- return NTFR(TFR.FAIL);
- }
-
- // - Garbage
- if (!Assert(callCountNon == -1))
- {
- return NTFR(TFR.FAIL);
- }
-
- // - Static
- if (!Assert(callCountS == 1))
- {
- return NTFR(TFR.FAIL);
- }
-
- // - Global
- if (!Assert(callCountG == 1))
- {
- return NTFR(TFR.FAIL);
- }
-
- // - Global proto
- if (!Assert(callCountGP == 0))
- {
- return NTFR(TFR.FAIL);
- }
-
- // - Static proto
- if (!Assert(callCountSP == 0))
- {
- return NTFR(TFR.FAIL);
- }
-
- // - proto
- if (!Assert(callCountP == 0))
- {
- return NTFR(TFR.FAIL);
- }
-
- // - proto native
- if (!Assert(callCountPN == 0))
- {
- return NTFR(TFR.FAIL);
- }
-
- // - static proto native
- if (!Assert(callCountSPN == 0))
- {
- return NTFR(TFR.FAIL);
- }
-
- return NTFR(TFR.SUCCESS);
- }
-
- //---------------------------------------------------------------------------
- // Helpers
- //---------------------------------------------------------------------------
- // Snore
- float Sleep(float timeS)
- {
- float startTime = GetGame().GetTickTime();
- while (GetGame().GetTickTime() - startTime < timeS)
- {
- // Zzz
- }
-
- return GetGame().GetTickTime() - startTime;
- }
-
- //---------------------------------------------------------------------------
- // Example stress method
- float StringFormat()
- {
- float startTime = GetGame().GetTickTime();
-
- for (int i = 0; i < 1000; ++i)
- {
- string example = string.Format("This %1 is %2 just %3 an %4 example %5", i, Type(), this, startTime, "lorem ipsum 1 2 3");
- }
-
- return GetGame().GetTickTime() - startTime;
- }
-
- //---------------------------------------------------------------------------
- // Example stress method 2
- float StringConcat()
- {
- float startTime = GetGame().GetTickTime();
-
- for (int i = 0; i < 1000; ++i)
- {
- string example = "This " + i + " is " + Type() + " just " + this + " an " + startTime + " example " + "lorem ipsum 1 2 3";
- }
-
- return GetGame().GetTickTime() - startTime;
- }
-
- //---------------------------------------------------------------------------
- // To make sure it is only ever called in that test
- void TestFuncCountDataHelper()
- {
- int dummy = 3;
- }
-
- //---------------------------------------------------------------------------
- // To make sure it is only ever called in that test
- static void TestFuncCountDataHelperStatic()
- {
- int dummy = 3;
- }
- }
- class EPTHelperClass
- {
- float Sleep2(float timeS)
- {
- float startTime = GetGame().GetTickTime();
- while (GetGame().GetTickTime() - startTime < timeS)
- {
- // Zzz
- }
-
- return GetGame().GetTickTime() - startTime;
- }
- float SleepAgain(float timeS)
- {
- float startTime = GetGame().GetTickTime();
- while (GetGame().GetTickTime() - startTime < timeS)
- {
- // Zzz
- }
-
- return GetGame().GetTickTime() - startTime;
- }
-
- float DoEverything()
- {
- float startTime = GetGame().GetTickTime();
-
- Sleep2(3);
- SleepAgain(3);
-
- return GetGame().GetTickTime() - startTime;
- }
- }
|