DayZ 1.24
Loading...
Searching...
No Matches
EnProfilerTests Class Reference
Inheritance diagram for EnProfilerTests:
[legend]
Collaboration diagram for EnProfilerTests:
[legend]

Private Member Functions

void EnProfilerTests ()
 
void ~EnProfilerTests ()
 
TFResult TestToggling ()
 
TFResult TestTogglingImmediate ()
 
TFResult TestSetFlags ()
 
TFResult TestClearFlags ()
 
TFResult TestAddFlags ()
 
TFResult TestModule ()
 
TFResult TestClassTimeData ()
 
TFResult TestClassCountData ()
 
TFResult TestFuncTimeData ()
 
TFResult TestFuncCountData ()
 
float Sleep (float timeS)
 
float StringFormat ()
 
float StringConcat ()
 
void TestFuncCountDataHelper ()
 

Static Private Member Functions

static void TestFuncCountDataHelperStatic ()
 

Private Attributes

bool m_bWasProfilerEnabled
 Remember this, so we can restore the previous state before the test!
 

Detailed Description

Definition at line 1 of file EnProfilerTests.c.

Constructor & Destructor Documentation

◆ EnProfilerTests()

void EnProfilerTests::EnProfilerTests ( )
inlineprivate

Definition at line 9 of file EnProfilerTests.c.

10 {
12
13 AddInitTest("TestToggling");
14 AddInitTest("TestTogglingImmediate");
15 AddInitTest("TestSetFlags");
16 AddInitTest("TestClearFlags");
17 AddInitTest("TestAddFlags");
18 AddInitTest("TestModule");
19 AddInitTest("TestClassTimeData");
20 AddInitTest("TestClassCountData");
21 AddInitTest("TestFuncTimeData");
22 AddInitTest("TestFuncCountData");
23 }
void AddInitTest(string test)
Set of methods for accessing script profiling data.
Definition EnProfiler.c:73
bool m_bWasProfilerEnabled
Remember this, so we can restore the previous state before the test!
static bool IsEnabledC()
Return if script profiling is actually turned on inside of the script context.
Definition EnProfiler.c:152

References AddInitTest(), EnProfiler::IsEnabledC(), and m_bWasProfilerEnabled.

◆ ~EnProfilerTests()

void EnProfilerTests::~EnProfilerTests ( )
inlineprivate

Definition at line 28 of file EnProfilerTests.c.

29 {
31 }
static proto void Enable(bool enable, bool immediate=false, bool sessionReset=true)
Enable the gathering of script profiling data.

References EnProfiler::Enable(), and m_bWasProfilerEnabled.

Member Function Documentation

◆ Sleep()

float EnProfilerTests::Sleep ( float timeS)
inlineprivate

Definition at line 647 of file EnProfilerTests.c.

648 {
649 float startTime = GetGame().GetTickTime();
650 while (GetGame().GetTickTime() - startTime < timeS)
651 {
652 // Zzz
653 }
654
655 return GetGame().GetTickTime() - startTime;
656 }
proto native CGame GetGame()

References GetGame().

Referenced by TestModule().

◆ StringConcat()

float EnProfilerTests::StringConcat ( )
inlineprivate

Definition at line 672 of file EnProfilerTests.c.

673 {
674 float startTime = GetGame().GetTickTime();
675
676 for (int i = 0; i < 1000; ++i)
677 string example = "This " + i + " is " + Type() + " just " + this + " an " + startTime + " example " + "lorem ipsum 1 2 3";
678
679 return GetGame().GetTickTime() - startTime;
680 }
string Type

References GetGame(), and Type.

Referenced by TestFuncTimeData().

◆ StringFormat()

float EnProfilerTests::StringFormat ( )
inlineprivate

Definition at line 660 of file EnProfilerTests.c.

661 {
662 float startTime = GetGame().GetTickTime();
663
664 for (int i = 0; i < 1000; ++i)
665 string example = string.Format("This %1 is %2 just %3 an %4 example %5", i, Type(), this, startTime, "lorem ipsum 1 2 3");
666
667 return GetGame().GetTickTime() - startTime;
668 }

References GetGame(), and Type.

Referenced by TestFuncTimeData().

◆ TestAddFlags()

TFResult EnProfilerTests::TestAddFlags ( )
inlineprivate

Definition at line 157 of file EnProfilerTests.c.

158 {
160
162
163 // Return should match resulting flags
165 {
167 return NTFR(TFR.FAIL);
168 }
169
170 if (!Assert(EnProfiler.GetFlags() == EnProfilerFlags.RESET))
171 {
173 return NTFR(TFR.FAIL);
174 }
175
176 if (!Assert(EnProfiler.AddFlags(EnProfilerFlags.RECURSIVE) == (EnProfilerFlags.RESET | EnProfilerFlags.RECURSIVE)))
177 {
179 return NTFR(TFR.FAIL);
180 }
181
182 // Reset
184 return NTFR(TFR.SUCCESS);
185 }
TFResult NTFR(TFR result)
bool Assert(bool condition)
TFR
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.
EnProfilerFlags
Flags that influences the behaviour of the EnProfiler API, applied through ...Flags functions.
Definition EnProfiler.c:9
static proto int SetFlags(int flags, bool sessionReset=true)
Override the currently used set of EnProfilerFlags across the API.
static proto int AddFlags(int flags, bool sessionReset=true)
Add flags to the currently used set of EnProfilerFlags across the API.

References EnProfiler::AddFlags(), Assert(), EnProfiler::ClearFlags(), EnProfiler::GetFlags(), NTFR(), and EnProfiler::SetFlags().

◆ TestClassCountData()

TFResult EnProfilerTests::TestClassCountData ( )
inlineprivate

Definition at line 415 of file EnProfilerTests.c.

416 {
417 const int allocAmount = 9;
418 const int releaseAmount = 6;
420
421 // We should restore this when done
423
424 // Time to test
427
429 for (int i = 0; i < allocAmount; ++i)
430 instanceArr.Insert(new EPTHelperClass());
431
432 for (int j = 0; j < releaseAmount; ++j)
433 delete instanceArr[j];
434
435 int postAlloc = EnProfiler.GetAllocationsOfClass(StaticGetType(EPTHelperClass), true);
437
440
441 Debug.TFLog(string.Format("Profiling result: alloc: %1 | instances: %2", alloced, instances), this, "TestClassCountData");
442
443 // Restore
444 if (!wasEnabled)
445 EnProfiler.Enable(false, true);
446
447 // Time to check
448 if (!Assert(alloced == allocAmount))
449 return NTFR(TFR.FAIL);
450
452 return NTFR(TFR.FAIL);
453
454 return NTFR(TFR.SUCCESS);
455 }
Definition Debug.c:14
static void TFLog(string message=LOG_DEFAULT, TestFramework caller=null, string function="")
Definition Debug.c:243
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 bool RequestImmediateData()
Helper method to ascertain the profiler will record [PD] right after this call.
Definition EnProfiler.c:735

References Assert(), EnProfiler::Enable(), EnProfiler::GetAllocationsOfClass(), EnProfiler::GetInstancesOfClass(), NTFR(), EnProfiler::RequestImmediateData(), and Debug::TFLog().

◆ TestClassTimeData()

TFResult EnProfilerTests::TestClassTimeData ( )
inlineprivate

Definition at line 373 of file EnProfilerTests.c.

374 {
375 // We should restore this when done
378
379 // GetTickTime() returns in seconds, so gather the results in seconds too
381
382 // Create the classes
384
385 // Time to stress
386 float previousTime = EnProfiler.GetTimeOfClass(clss.Type(), true);
387 float timeStressed = clss.DoEverything();
388 float postTime = EnProfiler.GetTimeOfClass(clss.Type(), true);
389 float postTimeStatic = EnProfiler.GetTimeOfClass(StaticGetType(EPTHelperClass), true);
392
393 Debug.TFLog(string.Format("Profiling result: stressed: %1 | profiled: %2 | diff: %3", timeStressed, timeProfiled, diff), this, "TestClassTimeData");
394
395 // Restore
397 if (!wasEnabled)
398 EnProfiler.Enable(false, true);
399
400 // We called the function, so it must have some time
401 if (!Assert(postTime > 0))
402 return NTFR(TFR.FAIL);
403
405 return NTFR(TFR.FAIL);
406
407 if (!Assert(diff < 0.001))
408 return NTFR(TFR.FAIL);
409
410 return NTFR(TFR.SUCCESS);
411 }
Definition EnMath.c:7
static proto float AbsFloat(float f)
Returns absolute value.
static proto int GetTimeResolution()
Get the currently set time resolution.
static proto float GetTimeOfClass(typename clss, bool immediate=false)
Obtain [SD] or [PD] regarding the time a specific class consumed.
static proto void SetTimeResolution(int resolution)
Set the resolution of the fetched Time data.

References Math::AbsFloat(), Assert(), EnProfiler::Enable(), EnProfiler::GetTimeOfClass(), EnProfiler::GetTimeResolution(), NTFR(), EnProfiler::RequestImmediateData(), EnProfiler::SetTimeResolution(), and Debug::TFLog().

◆ TestClearFlags()

TFResult EnProfilerTests::TestClearFlags ( )
inlineprivate

Definition at line 120 of file EnProfilerTests.c.

121 {
123
125
127 {
129 return NTFR(TFR.FAIL);
130 }
131
134
136 {
138 return NTFR(TFR.FAIL);
139 }
140
143
145 {
147 return NTFR(TFR.FAIL);
148 }
149
150 // Reset
152 return NTFR(TFR.SUCCESS);
153 }
static proto int RemoveFlags(int flags, bool sessionReset=true)
Remove flags from the currently used set of EnProfilerFlags across the API.

References Assert(), EnProfiler::ClearFlags(), EnProfiler::GetFlags(), NTFR(), EnProfiler::RemoveFlags(), and EnProfiler::SetFlags().

◆ TestFuncCountData()

TFResult EnProfilerTests::TestFuncCountData ( )
inlineprivate

Definition at line 510 of file EnProfilerTests.c.

511 {
512 // We should restore this when done
514
515 // Time to count
516
517 // - CallFunction
518 int previousCountCF = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
519 GetGame().GameScript.CallFunction(this, "TestFuncCountDataHelper", null, 0);
520 int postCountCF = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
521
523
524 // - CallFunctionParams
525 int previousCountCFP = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
526 GetGame().GameScript.CallFunctionParams(this, "TestFuncCountDataHelper", null, null);
527 int postCountCFP = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
528
530
531 // - Regular call
532 int previousCountRG = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
534 int postCountRG = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
535
537
538 // - Call
539 int previousCountC = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
540 GetGame().GameScript.Call(this, "TestFuncCountDataHelper", 0);
541 int postCountC = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
542
544
545 // - Garbage
546 int callCountNon = EnProfiler.GetCountOfFunc("Non Existing Method", Type(), true);
547
548 // - Static
549 int previousCountS = EnProfiler.GetCountOfFunc("TestFuncCountDataHelperStatic", Type(), true);
551 int postCountS = EnProfiler.GetCountOfFunc("TestFuncCountDataHelperStatic", Type(), true);
552
554
555 // - Global
556 int previousCountG = EnProfiler.GetCountOfFuncG("GetDayZGame", true);
557 GetDayZGame();
558 int postCountG = EnProfiler.GetCountOfFuncG("GetDayZGame", true);
559
561
562 // - Global proto
563 // Not tracked, so don't need to compare before and after, should always be 0
564 ErrorEx("Testing global proto call", ErrorExSeverity.INFO);
565 int callCountGP = EnProfiler.GetCountOfFuncG("ErrorEx", true);
566
567 // - Static proto
568 // Not tracked, so don't need to compare before and after, should always be 0
569 int callCountSP = EnProfiler.GetCountOfFunc("GetCountOfFunc", StaticGetType(EnProfiler), true);
570
571 // - proto
572 // Not tracked, so don't need to compare before and after, should always be 0
573 GetGame().GetHostName();
574 int callCountP = EnProfiler.GetCountOfFunc("GetHostName", GetGame().Type(), true);
575
576 // - proto native
577 // Not tracked, so don't need to compare before and after, should always be 0
578 GetGame().IsServer();
579 int callCountPN = EnProfiler.GetCountOfFunc("IsServer", GetGame().Type(), true);
580
581 // - static proto native
582 // Not tracked, so don't need to compare before and after, should always be 0
584 int callCountSPN = EnProfiler.GetCountOfFunc("GetInstance", StaticGetType(ErrorModuleHandler), true);
585
586 // Restore
587 if (!wasEnabled)
588 EnProfiler.Enable(false, true);
589
590 // Do the checks
591
592 // - CallFunction
593 if (!Assert(callCountCF == 1))
594 return NTFR(TFR.FAIL);
595
596 // - CallFunctionParams
597 if (!Assert(callCountCFP == 1))
598 return NTFR(TFR.FAIL);
599
600 // - Regular call
601 if (!Assert(callCountRG == 1))
602 return NTFR(TFR.FAIL);
603
604 // - Call
605 if (!Assert(callCountC == 1))
606 return NTFR(TFR.FAIL);
607
608 // - Garbage
609 if (!Assert(callCountNon == -1))
610 return NTFR(TFR.FAIL);
611
612 // - Static
613 if (!Assert(callCountS == 1))
614 return NTFR(TFR.FAIL);
615
616 // - Global
617 if (!Assert(callCountG == 1))
618 return NTFR(TFR.FAIL);
619
620 // - Global proto
621 if (!Assert(callCountGP == 0))
622 return NTFR(TFR.FAIL);
623
624 // - Static proto
625 if (!Assert(callCountSP == 0))
626 return NTFR(TFR.FAIL);
627
628 // - proto
629 if (!Assert(callCountP == 0))
630 return NTFR(TFR.FAIL);
631
632 // - proto native
633 if (!Assert(callCountPN == 0))
634 return NTFR(TFR.FAIL);
635
636 // - static proto native
637 if (!Assert(callCountSPN == 0))
638 return NTFR(TFR.FAIL);
639
640 return NTFR(TFR.SUCCESS);
641 }
DayZGame GetDayZGame()
Definition DayZGame.c:3530
void TestFuncCountDataHelper()
static void TestFuncCountDataHelperStatic()
The error handler itself, for managing and distributing errors to modules Manages the ErrorHandlerMod...
static proto native ErrorModuleHandler GetInstance()
Gets the EMH Instance.
ErrorExSeverity
Definition EnDebug.c:62
enum ShapeType ErrorEx
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.

References Assert(), EnProfiler::Enable(), ErrorEx, EnProfiler::GetCountOfFunc(), EnProfiler::GetCountOfFuncG(), GetDayZGame(), GetGame(), ErrorModuleHandler::GetInstance(), NTFR(), EnProfiler::RequestImmediateData(), TestFuncCountDataHelper(), TestFuncCountDataHelperStatic(), and Type.

◆ TestFuncCountDataHelper()

void EnProfilerTests::TestFuncCountDataHelper ( )
inlineprivate

Definition at line 684 of file EnProfilerTests.c.

685 {
686 int dummy = 3;
687 }

Referenced by TestFuncCountData().

◆ TestFuncCountDataHelperStatic()

static void EnProfilerTests::TestFuncCountDataHelperStatic ( )
inlinestaticprivate

Definition at line 691 of file EnProfilerTests.c.

692 {
693 int dummy = 3;
694 }

Referenced by TestFuncCountData().

◆ TestFuncTimeData()

TFResult EnProfilerTests::TestFuncTimeData ( )
inlineprivate

Definition at line 459 of file EnProfilerTests.c.

460 {
461 // We should restore this when done
464
465 // GetTickTime() returns in seconds, so gather the results in seconds too
467
468 // Time to stress
469 float previousTime = EnProfiler.GetTimeOfFunc("StringFormat", Type(), true);
470 float timeStressed = StringFormat();
471 float postTime = EnProfiler.GetTimeOfFunc("StringFormat", Type(), true);
474
475 float previousTime2 = EnProfiler.GetTimeOfFunc("StringConcat", Type(), true);
476 float timeStressed2 = StringConcat();
477 float postTime2 = EnProfiler.GetTimeOfFunc("StringConcat", Type(), true);
480
481 Debug.TFLog(string.Format("Profiling result: StringFormat: %1 | StringConcat: %2", timeProfiled, timeProfiled2), this, "TestFuncTimeData");
482
483 // Restore
485 if (!wasEnabled)
486 EnProfiler.Enable(false, true);
487
488 // We called the function, so it must have some time
489 if (!Assert(postTime > 0))
490 return NTFR(TFR.FAIL);
491
492 if (!Assert(diff < 0.001))
493 return NTFR(TFR.FAIL);
494
495 if (!Assert(postTime2 > 0))
496 return NTFR(TFR.FAIL);
497
498 if (!Assert(diff2 < 0.001))
499 return NTFR(TFR.FAIL);
500
501 // I know that string.Format is faster than additive concatenation
503 return NTFR(TFR.FAIL);
504
505 return NTFR(TFR.SUCCESS);
506 }
static proto float GetTimeOfFunc(string funct, typename clss, bool immediate=false)
Obtain [SD] or [PD] regarding the time consumed by a specific function.

References Math::AbsFloat(), Assert(), EnProfiler::Enable(), EnProfiler::GetTimeOfFunc(), EnProfiler::GetTimeResolution(), NTFR(), EnProfiler::RequestImmediateData(), EnProfiler::SetTimeResolution(), StringConcat(), StringFormat(), Debug::TFLog(), and Type.

◆ TestModule()

TFResult EnProfilerTests::TestModule ( )
inlineprivate

Definition at line 189 of file EnProfilerTests.c.

190 {
191 // File lives in Game, use it while testing
193
194 // This was added at the same time as this API, so check if it works as well
195 string nameOfCurrentModule = Type().GetModule();
196 if (!Assert(nameOfCurrentModule != ""))
197 return NTFR(TFR.FAIL);
198
199 // We know we are in Game, so use it as a test
202 return NTFR(TFR.FAIL);
203
205 return NTFR(TFR.FAIL);
206
207 // Test if setting and getting works
210
212 {
214 return NTFR(TFR.FAIL);
215 }
216
217 // Data to restore
220
221 // Make sure we are only profiling Game and that the data is clean
222 // Only valid for the Get...Per... methods, as they need to be sorted
224
225 // GetTickTime() returns in seconds, so gather the results in seconds too
228
229 // Time to sleeb
230 float previousTime = EnProfiler.GetTimeOfFunc("Sleep", Type(), true);
231 float timeSlept = Sleep(0.3);
232 float postTime = EnProfiler.GetTimeOfFunc("Sleep", Type(), true);
234
235 // Restore
237
238 // We called the function, so it must have some time
239 if (!Assert(postTime > 0))
240 {
242
243 if (!wasEnabled)
244 EnProfiler.Enable(false, true);
245
247
248 return NTFR(TFR.FAIL);
249 }
250
251 if (!Assert(diff < 0.00001))
252 {
254
255 if (!wasEnabled)
256 EnProfiler.Enable(false, true);
257
259
260 return NTFR(TFR.FAIL);
261 }
262
263 // Clean the session
265
266 // Something from a different module should not get sorted, so just fire something from a different module
267 for (int i = 0; i < 1000; ++i)
268 EnumTools.StringToEnum(EnProfilerModule, "MISSION_CUSTOM");
269
270 // Sort and gather the data and validate if it is correct
274
275 Debug.TFLog("Game fncs:", this, "TestModule");
276
277 int funcCount = timePerFunc.Count();
278 for (int j = 0; j < funcCount; ++j)
279 {
281 Debug.TFLog(string.Format(" time: %1 | fnc: %2", tfp.param1, tfp.param2), this, "TestModule");
282 // We are currently profiling Game, so this Core function shouldn't be present
283 if (!Assert(tfp.param2 != "EnumTools::StringToEnum"))
284 {
286
287 if (!wasEnabled)
288 EnProfiler.Enable(false, true);
289
291
292 return NTFR(TFR.FAIL);
293 }
294 }
295
298
299 int classCount = timePerClass.Count();
300 for (int k = 0; k < classCount; ++k)
301 {
302 typename type = timePerClass[k].param2;
304 if (!Assert(EnProfiler.NameToModule(type.GetModule(), classModule)))
305 {
307
308 if (!wasEnabled)
309 EnProfiler.Enable(false, true);
310
312
313 return NTFR(TFR.FAIL);
314 }
315
316 // Only classes from Game should be present
318 {
320
321 if (!wasEnabled)
322 EnProfiler.Enable(false, true);
323
325
326 return NTFR(TFR.FAIL);
327 }
328 }
329
330 // Now let's check if we can gather the data of what we called earlier by switching the profiled module without resetting the session
333 timePerFunc.Clear(); // Let's reuse the array, but the Get...Per... methods only appends to the array, clearing is our responsibility
335
336 bool found = false;
337
338 Debug.TFLog("Core fncs:", this, "TestModule");
339
340 funcCount = timePerFunc.Count();
341 for (int l = 0; l < funcCount; ++l)
342 {
344 Debug.TFLog(string.Format(" time: %1 | fnc: %2", tfpc.param1, tfpc.param2), this, "TestModule");
345 // We are currently profiling Core, so this Core function should be present
346 if (tfpc.param2 == "EnumTools::StringToEnum")
347 {
348 found = true;
349 break;
350 }
351 }
352
353 Assert(found);
354
355 // Test some bogus
357 EnProfiler.SetModule(-333);
359 EnProfiler.SetModule(6003);
361
364
365 if (!wasEnabled)
366 EnProfiler.Enable(false, true);
367
368 return BTFR(success && found);
369 }
TFResult BTFR(bool result)
float Sleep(float timeS)
static int StringToEnum(typename e, string enumName)
Return enum value from string name.
Definition EnConvert.c:609
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.
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 proto void GetTimePerClass(notnull out array< ref EnProfilerTimeClassPair > outArr, int count=int.MAX)
Obtain [SD] for Time Per Class.
EnProfilerModule
Current base scripted modules.
Definition EnProfiler.c:22
static proto bool NameToModule(string moduleName, out EnProfilerModule module)
Convert string to EnProfilerModule.

References Assert(), BTFR(), EnProfiler::Enable(), EnProfiler::GetFlags(), EnProfiler::GetModule(), EnProfiler::GetTimeOfFunc(), EnProfiler::GetTimePerClass(), EnProfiler::GetTimePerFunc(), EnProfiler::GetTimeResolution(), EnProfiler::NameToModule(), NTFR(), EnProfiler::RemoveFlags(), EnProfiler::RequestImmediateData(), EnProfiler::ResetSession(), EnProfiler::SetFlags(), EnProfiler::SetModule(), EnProfiler::SetTimeResolution(), Sleep(), EnProfiler::SortData(), EnumTools::StringToEnum(), Debug::TFLog(), and Type.

◆ TestSetFlags()

TFResult EnProfilerTests::TestSetFlags ( )
inlineprivate

Definition at line 67 of file EnProfilerTests.c.

68 {
70
71 for (int i = 0; i < EnumTools.GetEnumSize(EnProfilerFlags); ++i)
72 {
74 EnProfiler.SetFlags(flags);
75
76 if (!Assert(EnProfiler.GetFlags() == flags))
77 {
79 return NTFR(TFR.FAIL);
80 }
81
82 for (int j = 0; j < EnumTools.GetEnumSize(EnProfilerFlags); ++j)
83 {
85 EnProfiler.SetFlags(flags);
86
87 if (!Assert(EnProfiler.GetFlags() == flags))
88 {
90 return NTFR(TFR.FAIL);
91 }
92 }
93 }
94
95 // Let's test some bogus
96 EnProfiler.SetFlags(-333);
99 if (!Assert(bogusFlags == 0))
100 {
102 return NTFR(TFR.FAIL);
103 }
104
107 if (!Assert(bogusFlags == 0))
108 {
110 return NTFR(TFR.FAIL);
111 }
112
113 // Reset
115 return NTFR(TFR.SUCCESS);
116 }
static int GetEnumSize(typename e)
Return amount of values in enum.
Definition EnConvert.c:620
static int GetEnumValue(typename e, int idx)
Return the nth value in the enum.
Definition EnConvert.c:631

References Assert(), EnumTools::GetEnumSize(), EnumTools::GetEnumValue(), EnProfiler::GetFlags(), NTFR(), and EnProfiler::SetFlags().

◆ TestToggling()

TFResult EnProfilerTests::TestToggling ( )
inlineprivate

Definition at line 37 of file EnProfilerTests.c.

38 {
42 {
45 }
46
47 return NTFR(TFR.FAIL);
48 }
static bool IsEnabledP()
Return if script profiling is enabled through EnProfiler.
Definition EnProfiler.c:138

References Assert(), BTFR(), EnProfiler::Enable(), EnProfiler::IsEnabledP(), and NTFR().

◆ TestTogglingImmediate()

TFResult EnProfilerTests::TestTogglingImmediate ( )
inlineprivate

Member Data Documentation

◆ m_bWasProfilerEnabled

bool EnProfilerTests::m_bWasProfilerEnabled
private

Remember this, so we can restore the previous state before the test!

Definition at line 4 of file EnProfilerTests.c.

Referenced by EnProfilerTests(), and ~EnProfilerTests().


The documentation for this class was generated from the following file: