DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ TestToggling()

TFResult Sleep2::TestToggling ( )

См. определение в файле EnProfilerTests.c строка 798

799{
802
803 //---------------------------------------------------------------------------
804 // Ctor - Decides the tests to run
805 //---------------------------------------------------------------------------
806 void EnProfilerTests()
807 {
809
810 AddInitTest("TestToggling");
811 AddInitTest("TestTogglingImmediate");
812 AddInitTest("TestSetFlags");
813 AddInitTest("TestClearFlags");
814 AddInitTest("TestAddFlags");
815 AddInitTest("TestModule");
816 AddInitTest("TestClassTimeData");
817 AddInitTest("TestClassCountData");
818 AddInitTest("TestFuncTimeData");
819 AddInitTest("TestFuncCountData");
820 }
821
822 //---------------------------------------------------------------------------
823 // Dtor
824 //---------------------------------------------------------------------------
825 void ~EnProfilerTests()
826 {
828 }
829
830 //---------------------------------------------------------------------------
831 // Tests
832 //---------------------------------------------------------------------------
833 // Test toggling state
835 {
836 bool currentlyEnabled = EnProfiler.IsEnabledP();
837 EnProfiler.Enable(!currentlyEnabled);
838 if (Assert(currentlyEnabled != EnProfiler.IsEnabledP()))
839 {
840 EnProfiler.Enable(currentlyEnabled);
841 return BTFR(Assert(currentlyEnabled == EnProfiler.IsEnabledP()));
842 }
843
844 return NTFR(TFR.FAIL);
845 }
846
847 //---------------------------------------------------------------------------
848 // Test toggling immediate state
850 {
851 bool currentlyEnabled = EnProfiler.IsEnabledC();
852 EnProfiler.Enable(!currentlyEnabled, true);
853 if (Assert(currentlyEnabled != EnProfiler.IsEnabledC()))
854 {
855 EnProfiler.Enable(currentlyEnabled, true);
856 return BTFR(Assert(currentlyEnabled == EnProfiler.IsEnabledC()));
857 }
858
859 return NTFR(TFR.FAIL);
860 }
861
862 //---------------------------------------------------------------------------
863 // Test SetFlags/GetFlags
865 {
866 int currentFlags = EnProfiler.GetFlags();
867
868 for (int i = 0; i < EnumTools.GetEnumSize(EnProfilerFlags); ++i)
869 {
870 int flags = EnumTools.GetEnumValue(EnProfilerFlags, i);
871 EnProfiler.SetFlags(flags);
872
873 if (!Assert(EnProfiler.GetFlags() == flags))
874 {
875 EnProfiler.SetFlags(currentFlags);
876 return NTFR(TFR.FAIL);
877 }
878
879 for (int j = 0; j < EnumTools.GetEnumSize(EnProfilerFlags); ++j)
880 {
882 EnProfiler.SetFlags(flags);
883
884 if (!Assert(EnProfiler.GetFlags() == flags))
885 {
886 EnProfiler.SetFlags(currentFlags);
887 return NTFR(TFR.FAIL);
888 }
889 }
890 }
891
892 // Let's test some bogus
893 EnProfiler.SetFlags(-333);
894 int bogusFlags = EnProfiler.GetFlags();
895 bogusFlags &= ~EnProfilerFlags.ALL;
896 if (!Assert(bogusFlags == 0))
897 {
898 EnProfiler.SetFlags(currentFlags);
899 return NTFR(TFR.FAIL);
900 }
901
902 bogusFlags = EnProfiler.SetFlags(6003);
903 bogusFlags &= ~EnProfilerFlags.ALL;
904 if (!Assert(bogusFlags == 0))
905 {
906 EnProfiler.SetFlags(currentFlags);
907 return NTFR(TFR.FAIL);
908 }
909
910 // Reset
911 EnProfiler.SetFlags(currentFlags);
912 return NTFR(TFR.SUCCESS);
913 }
914
915 //---------------------------------------------------------------------------
916 // Test removing of flags
918 {
919 int currentFlags = EnProfiler.GetFlags();
920
922
924 {
925 EnProfiler.SetFlags(currentFlags);
926 return NTFR(TFR.FAIL);
927 }
928
931
933 {
934 EnProfiler.SetFlags(currentFlags);
935 return NTFR(TFR.FAIL);
936 }
937
940
942 {
943 EnProfiler.SetFlags(currentFlags);
944 return NTFR(TFR.FAIL);
945 }
946
947 // Reset
948 EnProfiler.SetFlags(currentFlags);
949 return NTFR(TFR.SUCCESS);
950 }
951
952 //---------------------------------------------------------------------------
953 // Test adding of flags
955 {
956 int currentFlags = EnProfiler.GetFlags();
957
959
960 // Return should match resulting flags
962 {
963 EnProfiler.SetFlags(currentFlags);
964 return NTFR(TFR.FAIL);
965 }
966
967 if (!Assert(EnProfiler.GetFlags() == EnProfilerFlags.RESET))
968 {
969 EnProfiler.SetFlags(currentFlags);
970 return NTFR(TFR.FAIL);
971 }
972
973 if (!Assert(EnProfiler.AddFlags(EnProfilerFlags.RECURSIVE) == (EnProfilerFlags.RESET | EnProfilerFlags.RECURSIVE)))
974 {
975 EnProfiler.SetFlags(currentFlags);
976 return NTFR(TFR.FAIL);
977 }
978
979 // Reset
980 EnProfiler.SetFlags(currentFlags);
981 return NTFR(TFR.SUCCESS);
982 }
983
984 //---------------------------------------------------------------------------
985 // Test module
987 {
988 // File lives in Game, use it while testing
989 const EnProfilerModule eptModule = EnProfilerModule.GAME;
990
991 // This was added at the same time as this API, so check if it works as well
992 string nameOfCurrentModule = Type().GetModule();
993 if (!Assert(nameOfCurrentModule != ""))
994 {
995 return NTFR(TFR.FAIL);
996 }
997
998 // We know we are in Game, so use it as a test
999 EnProfilerModule currentModule;
1000 if (!Assert(EnProfiler.NameToModule(nameOfCurrentModule, currentModule)))
1001 {
1002 return NTFR(TFR.FAIL);
1003 }
1004
1005 if (!Assert(currentModule == eptModule))
1006 {
1007 return NTFR(TFR.FAIL);
1008 }
1009
1010 // Test if setting and getting works
1011 EnProfilerModule currentlyProfiledModule = EnProfiler.GetModule();
1012 EnProfiler.SetModule(eptModule);
1013
1014 if (!Assert(EnProfiler.GetModule() == eptModule))
1015 {
1016 EnProfiler.SetModule(currentlyProfiledModule);
1017 return NTFR(TFR.FAIL);
1018 }
1019
1020 // Data to restore
1021 int currentFlags = EnProfiler.GetFlags();
1022 bool wasEnabled = EnProfiler.RequestImmediateData();
1023
1024 // Make sure we are only profiling Game and that the data is clean
1025 // Only valid for the Get...Per... methods, as they need to be sorted
1027
1028 // GetTickTime() returns in seconds, so gather the results in seconds too
1029 int resolution = EnProfiler.GetTimeResolution();
1031
1032 // Time to sleeb
1033 float previousTime = EnProfiler.GetTimeOfFunc("Sleep", Type(), true);
1034 float timeSlept = Sleep(0.3);
1035 float postTime = EnProfiler.GetTimeOfFunc("Sleep", Type(), true);
1036 float diff = postTime - previousTime - timeSlept;
1037
1038 // Restore
1039 EnProfiler.SetTimeResolution(resolution);
1040
1041 // We called the function, so it must have some time
1042 if (!Assert(postTime > 0))
1043 {
1044 EnProfiler.SetFlags(currentFlags);
1045
1046 if (!wasEnabled)
1047 EnProfiler.Enable(false, true);
1048
1049 EnProfiler.SetModule(currentlyProfiledModule);
1050
1051 return NTFR(TFR.FAIL);
1052 }
1053
1054 if (!Assert(diff < 0.00001))
1055 {
1056 EnProfiler.SetFlags(currentFlags);
1057
1058 if (!wasEnabled)
1059 EnProfiler.Enable(false, true);
1060
1061 EnProfiler.SetModule(currentlyProfiledModule);
1062
1063 return NTFR(TFR.FAIL);
1064 }
1065
1066 // Clean the session
1068
1069 // Something from a different module should not get sorted, so just fire something from a different module
1070 for (int i = 0; i < 1000; ++i)
1071 {
1072 EnumTools.StringToEnum(EnProfilerModule, "MISSION_CUSTOM");
1073 }
1074
1075 // Sort and gather the data and validate if it is correct
1077 array<ref EnProfilerTimeFuncPair> timePerFunc = {};
1078 EnProfiler.GetTimePerFunc(timePerFunc);
1079
1080 Debug.TFLog("Game fncs:", this, "TestModule");
1081
1082 int funcCount = timePerFunc.Count();
1083 for (int j = 0; j < funcCount; ++j)
1084 {
1085 EnProfilerTimeFuncPair tfp = timePerFunc[j];
1086 Debug.TFLog(string.Format(" time: %1 | fnc: %2", tfp.param1, tfp.param2), this, "TestModule");
1087 // We are currently profiling Game, so this Core function shouldn't be present
1088 if (!Assert(tfp.param2 != "EnumTools::StringToEnum"))
1089 {
1090 EnProfiler.SetFlags(currentFlags);
1091
1092 if (!wasEnabled)
1093 EnProfiler.Enable(false, true);
1094
1095 EnProfiler.SetModule(currentlyProfiledModule);
1096
1097 return NTFR(TFR.FAIL);
1098 }
1099 }
1100
1101 array<ref EnProfilerTimeClassPair> timePerClass = {};
1102 EnProfiler.GetTimePerClass(timePerClass);
1103
1104 int classCount = timePerClass.Count();
1105 for (int k = 0; k < classCount; ++k)
1106 {
1107 typename type = timePerClass[k].param2;
1108 EnProfilerModule classModule;
1109 if (!Assert(EnProfiler.NameToModule(type.GetModule(), classModule)))
1110 {
1111 EnProfiler.SetFlags(currentFlags);
1112
1113 if (!wasEnabled)
1114 EnProfiler.Enable(false, true);
1115
1116 EnProfiler.SetModule(currentlyProfiledModule);
1117
1118 return NTFR(TFR.FAIL);
1119 }
1120
1121 // Only classes from Game should be present
1122 if (!Assert(classModule == eptModule))
1123 {
1124 EnProfiler.SetFlags(currentFlags);
1125
1126 if (!wasEnabled)
1127 EnProfiler.Enable(false, true);
1128
1129 EnProfiler.SetModule(currentlyProfiledModule);
1130
1131 return NTFR(TFR.FAIL);
1132 }
1133 }
1134
1135 // Now let's check if we can gather the data of what we called earlier by switching the profiled module without resetting the session
1138 timePerFunc.Clear(); // Let's reuse the array, but the Get...Per... methods only appends to the array, clearing is our responsibility
1139 EnProfiler.GetTimePerFunc(timePerFunc);
1140
1141 bool found = false;
1142
1143 Debug.TFLog("Core fncs:", this, "TestModule");
1144
1145 funcCount = timePerFunc.Count();
1146 for (int l = 0; l < funcCount; ++l)
1147 {
1148 EnProfilerTimeFuncPair tfpc = timePerFunc[l];
1149 Debug.TFLog(string.Format(" time: %1 | fnc: %2", tfpc.param1, tfpc.param2), this, "TestModule");
1150 // We are currently profiling Core, so this Core function should be present
1151 if (tfpc.param2 == "EnumTools::StringToEnum")
1152 {
1153 found = true;
1154 break;
1155 }
1156 }
1157
1158 Assert(found);
1159
1160 // Test some bogus
1162 EnProfiler.SetModule(-333);
1163 bool success = Assert(EnProfiler.GetModule() == mod);
1164 EnProfiler.SetModule(6003);
1165 success &= Assert(EnProfiler.GetModule() == mod);
1166
1167 EnProfiler.SetFlags(currentFlags);
1168 EnProfiler.SetModule(currentlyProfiledModule);
1169
1170 if (!wasEnabled)
1171 EnProfiler.Enable(false, true);
1172
1173 return BTFR(success && found);
1174 }
1175
1176 //---------------------------------------------------------------------------
1177 // Test to see if class time data is correct
1179 {
1180 // We should restore this when done
1181 int resolution = EnProfiler.GetTimeResolution();
1182 bool wasEnabled = EnProfiler.RequestImmediateData();
1183
1184 // GetTickTime() returns in seconds, so gather the results in seconds too
1186
1187 // Create the classes
1188 EPTHelperClass clss = new EPTHelperClass();
1189
1190 // Time to stress
1191 float previousTime = EnProfiler.GetTimeOfClass(clss.Type(), true);
1192 float timeStressed = clss.DoEverything();
1193 float postTime = EnProfiler.GetTimeOfClass(clss.Type(), true);
1194 float postTimeStatic = EnProfiler.GetTimeOfClass(StaticGetType(EPTHelperClass), true);
1195 float timeProfiled = postTime - previousTime;
1196 float diff = Math.AbsFloat(timeProfiled - timeStressed);
1197
1198 Debug.TFLog(string.Format("Profiling result: stressed: %1 | profiled: %2 | diff: %3", timeStressed, timeProfiled, diff), this, "TestClassTimeData");
1199
1200 // Restore
1201 EnProfiler.SetTimeResolution(resolution);
1202 if (!wasEnabled)
1203 EnProfiler.Enable(false, true);
1204
1205 // We called the function, so it must have some time
1206 if (!Assert(postTime > 0))
1207 {
1208 return NTFR(TFR.FAIL);
1209 }
1210
1211 if (!Assert(postTime == postTimeStatic))
1212 {
1213 return NTFR(TFR.FAIL);
1214 }
1215
1216 if (!Assert(diff < 0.001))
1217 {
1218 return NTFR(TFR.FAIL);
1219 }
1220
1221 return NTFR(TFR.SUCCESS);
1222 }
1223
1224 //---------------------------------------------------------------------------
1225 // Test to see if class count data is correct
1227 {
1228 const int allocAmount = 9;
1229 const int releaseAmount = 6;
1230 int remainingAmount = allocAmount - releaseAmount;
1231
1232 // We should restore this when done
1233 bool wasEnabled = EnProfiler.RequestImmediateData();
1234
1235 // Time to test
1236 int previousAlloc = EnProfiler.GetAllocationsOfClass(StaticGetType(EPTHelperClass), true);
1237 int previousInstances = EnProfiler.GetInstancesOfClass(StaticGetType(EPTHelperClass), true);
1238
1239 array<ref EPTHelperClass> instanceArr = {};
1240 for (int i = 0; i < allocAmount; ++i)
1241 {
1242 instanceArr.Insert(new EPTHelperClass());
1243 }
1244
1245 for (int j = 0; j < releaseAmount; ++j)
1246 {
1247 delete instanceArr[j];
1248 }
1249
1250 int postAlloc = EnProfiler.GetAllocationsOfClass(StaticGetType(EPTHelperClass), true);
1251 int postInstances = EnProfiler.GetInstancesOfClass(StaticGetType(EPTHelperClass), true);
1252
1253 int alloced = postAlloc - previousAlloc;
1254 int instances = postInstances - previousInstances;
1255
1256 Debug.TFLog(string.Format("Profiling result: alloc: %1 | instances: %2", alloced, instances), this, "TestClassCountData");
1257
1258 // Restore
1259 if (!wasEnabled)
1260 EnProfiler.Enable(false, true);
1261
1262 // Time to check
1263 if (!Assert(alloced == allocAmount))
1264 {
1265 return NTFR(TFR.FAIL);
1266 }
1267
1268 if (!Assert(instances == remainingAmount))
1269 {
1270 return NTFR(TFR.FAIL);
1271 }
1272
1273 return NTFR(TFR.SUCCESS);
1274 }
1275
1276 //---------------------------------------------------------------------------
1277 // Test to see if func time data is correct
1279 {
1280 // We should restore this when done
1281 int resolution = EnProfiler.GetTimeResolution();
1282 bool wasEnabled = EnProfiler.RequestImmediateData();
1283
1284 // GetTickTime() returns in seconds, so gather the results in seconds too
1286
1287 // Time to stress
1288 float previousTime = EnProfiler.GetTimeOfFunc("StringFormat", Type(), true);
1289 float timeStressed = StringFormat();
1290 float postTime = EnProfiler.GetTimeOfFunc("StringFormat", Type(), true);
1291 float timeProfiled = postTime - previousTime;
1292 float diff = Math.AbsFloat(timeProfiled - timeStressed);
1293
1294 float previousTime2 = EnProfiler.GetTimeOfFunc("StringConcat", Type(), true);
1295 float timeStressed2 = StringConcat();
1296 float postTime2 = EnProfiler.GetTimeOfFunc("StringConcat", Type(), true);
1297 float timeProfiled2 = postTime2 - previousTime2;
1298 float diff2 = Math.AbsFloat(timeProfiled2 - timeStressed2);
1299
1300 Debug.TFLog(string.Format("Profiling result: StringFormat: %1 | StringConcat: %2", timeProfiled, timeProfiled2), this, "TestFuncTimeData");
1301
1302 // Restore
1303 EnProfiler.SetTimeResolution(resolution);
1304 if (!wasEnabled)
1305 {
1306 EnProfiler.Enable(false, true);
1307 }
1308
1309 // We called the function, so it must have some time
1310 if (!Assert(postTime > 0))
1311 {
1312 return NTFR(TFR.FAIL);
1313 }
1314
1315 if (!Assert(diff < 0.001))
1316 {
1317 return NTFR(TFR.FAIL);
1318 }
1319
1320 if (!Assert(postTime2 > 0))
1321 {
1322 return NTFR(TFR.FAIL);
1323 }
1324
1325 if (!Assert(diff2 < 0.001))
1326 {
1327 return NTFR(TFR.FAIL);
1328 }
1329
1330 // I know that string.Format is faster than additive concatenation
1331 if (!Assert(timeProfiled < timeProfiled2))
1332 {
1333 return NTFR(TFR.FAIL);
1334 }
1335
1336 return NTFR(TFR.SUCCESS);
1337 }
1338
1339 //---------------------------------------------------------------------------
1340 // Test to see if func count data is correct
1342 {
1343 // We should restore this when done
1344 bool wasEnabled = EnProfiler.RequestImmediateData();
1345
1346 // Time to count
1347
1348 // - CallFunction
1349 int previousCountCF = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
1350 GetGame().GameScript.CallFunction(this, "TestFuncCountDataHelper", null, 0);
1351 int postCountCF = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
1352
1353 int callCountCF = postCountCF - previousCountCF;
1354
1355 // - CallFunctionParams
1356 int previousCountCFP = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
1357 GetGame().GameScript.CallFunctionParams(this, "TestFuncCountDataHelper", null, null);
1358 int postCountCFP = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
1359
1360 int callCountCFP = postCountCFP - previousCountCFP;
1361
1362 // - Regular call
1363 int previousCountRG = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
1365 int postCountRG = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
1366
1367 int callCountRG = postCountRG - previousCountRG;
1368
1369 // - Call
1370 int previousCountC = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
1371 GetGame().GameScript.Call(this, "TestFuncCountDataHelper", 0);
1372 int postCountC = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
1373
1374 int callCountC = postCountC - previousCountC;
1375
1376 // - Garbage
1377 int callCountNon = EnProfiler.GetCountOfFunc("Non Existing Method", Type(), true);
1378
1379 // - Static
1380 int previousCountS = EnProfiler.GetCountOfFunc("TestFuncCountDataHelperStatic", Type(), true);
1382 int postCountS = EnProfiler.GetCountOfFunc("TestFuncCountDataHelperStatic", Type(), true);
1383
1384 int callCountS = postCountS - previousCountS;
1385
1386 // - Global
1387 int previousCountG = EnProfiler.GetCountOfFuncG("GetDayZGame", true);
1388 GetDayZGame();
1389 int postCountG = EnProfiler.GetCountOfFuncG("GetDayZGame", true);
1390
1391 int callCountG = postCountG - previousCountG;
1392
1393 // - Global proto
1394 // Not tracked, so don't need to compare before and after, should always be 0
1395 ErrorEx("Testing global proto call", ErrorExSeverity.INFO);
1396 int callCountGP = EnProfiler.GetCountOfFuncG("ErrorEx", true);
1397
1398 // - Static proto
1399 // Not tracked, so don't need to compare before and after, should always be 0
1400 int callCountSP = EnProfiler.GetCountOfFunc("GetCountOfFunc", StaticGetType(EnProfiler), true);
1401
1402 // - proto
1403 // Not tracked, so don't need to compare before and after, should always be 0
1404 GetGame().GetHostName();
1405 int callCountP = EnProfiler.GetCountOfFunc("GetHostName", GetGame().Type(), true);
1406
1407 // - proto native
1408 // Not tracked, so don't need to compare before and after, should always be 0
1409 GetGame().IsServer();
1410 int callCountPN = EnProfiler.GetCountOfFunc("IsServer", GetGame().Type(), true);
1411
1412 // - static proto native
1413 // Not tracked, so don't need to compare before and after, should always be 0
1415 int callCountSPN = EnProfiler.GetCountOfFunc("GetInstance", StaticGetType(ErrorModuleHandler), true);
1416
1417 // Restore
1418 if (!wasEnabled)
1419 {
1420 EnProfiler.Enable(false, true);
1421 }
1422
1423 // Do the checks
1424
1425 // - CallFunction
1426 if (!Assert(callCountCF == 1))
1427 {
1428 return NTFR(TFR.FAIL);
1429 }
1430
1431 // - CallFunctionParams
1432 if (!Assert(callCountCFP == 1))
1433 {
1434 return NTFR(TFR.FAIL);
1435 }
1436
1437 // - Regular call
1438 if (!Assert(callCountRG == 1))
1439 {
1440 return NTFR(TFR.FAIL);
1441 }
1442
1443 // - Call
1444 if (!Assert(callCountC == 1))
1445 {
1446 return NTFR(TFR.FAIL);
1447 }
1448
1449 // - Garbage
1450 if (!Assert(callCountNon == -1))
1451 {
1452 return NTFR(TFR.FAIL);
1453 }
1454
1455 // - Static
1456 if (!Assert(callCountS == 1))
1457 {
1458 return NTFR(TFR.FAIL);
1459 }
1460
1461 // - Global
1462 if (!Assert(callCountG == 1))
1463 {
1464 return NTFR(TFR.FAIL);
1465 }
1466
1467 // - Global proto
1468 if (!Assert(callCountGP == 0))
1469 {
1470 return NTFR(TFR.FAIL);
1471 }
1472
1473 // - Static proto
1474 if (!Assert(callCountSP == 0))
1475 {
1476 return NTFR(TFR.FAIL);
1477 }
1478
1479 // - proto
1480 if (!Assert(callCountP == 0))
1481 {
1482 return NTFR(TFR.FAIL);
1483 }
1484
1485 // - proto native
1486 if (!Assert(callCountPN == 0))
1487 {
1488 return NTFR(TFR.FAIL);
1489 }
1490
1491 // - static proto native
1492 if (!Assert(callCountSPN == 0))
1493 {
1494 return NTFR(TFR.FAIL);
1495 }
1496
1497 return NTFR(TFR.SUCCESS);
1498 }
1499
1500 //---------------------------------------------------------------------------
1501 // Helpers
1502 //---------------------------------------------------------------------------
1503 // Snore
1504 float Sleep(float timeS)
1505 {
1506 float startTime = GetGame().GetTickTime();
1507 while (GetGame().GetTickTime() - startTime < timeS)
1508 {
1509 // Zzz
1510 }
1511
1512 return GetGame().GetTickTime() - startTime;
1513 }
1514
1515 //---------------------------------------------------------------------------
1516 // Example stress method
1517 float StringFormat()
1518 {
1519 float startTime = GetGame().GetTickTime();
1520
1521 for (int i = 0; i < 1000; ++i)
1522 {
1523 string example = string.Format("This %1 is %2 just %3 an %4 example %5", i, Type(), this, startTime, "lorem ipsum 1 2 3");
1524 }
1525
1526 return GetGame().GetTickTime() - startTime;
1527 }
1528
1529 //---------------------------------------------------------------------------
1530 // Example stress method 2
1531 float StringConcat()
1532 {
1533 float startTime = GetGame().GetTickTime();
1534
1535 for (int i = 0; i < 1000; ++i)
1536 {
1537 string example = "This " + i + " is " + Type() + " just " + this + " an " + startTime + " example " + "lorem ipsum 1 2 3";
1538 }
1539
1540 return GetGame().GetTickTime() - startTime;
1541 }
1542
1543 //---------------------------------------------------------------------------
1544 // To make sure it is only ever called in that test
1546 {
1547 int dummy = 3;
1548 }
1549
1550 //---------------------------------------------------------------------------
1551 // To make sure it is only ever called in that test
1552 static void TestFuncCountDataHelperStatic()
1553 {
1554 int dummy = 3;
1555 }
1556}
1557
1558class EPTHelperClass
1559{
1560 float Sleep2(float timeS)
1561 {
1562 float startTime = GetGame().GetTickTime();
1563 while (GetGame().GetTickTime() - startTime < timeS)
1564 {
1565 // Zzz
1566 }
1567
1568 return GetGame().GetTickTime() - startTime;
1569 }
1570 float SleepAgain(float timeS)
1571 {
1572 float startTime = GetGame().GetTickTime();
1573 while (GetGame().GetTickTime() - startTime < timeS)
1574 {
1575 // Zzz
1576 }
1577
1578 return GetGame().GetTickTime() - startTime;
1579 }
1580
1581 float DoEverything()
1582 {
1583 float startTime = GetGame().GetTickTime();
1584
1585 Sleep2(3);
1586 SleepAgain(3);
1587
1588 return GetGame().GetTickTime() - startTime;
1589 }
1590}
DayZGame GetDayZGame()
Определения DayZGame.c:3870
float StringConcat()
Определения EnProfilerTests.c:1495
float SleepAgain(float timeS)
Определения EnProfilerTests.c:773
float Sleep(float timeS)
Определения EnProfilerTests.c:1468
void TestFuncCountDataHelper()
Определения EnProfilerTests.c:1509
void EnProfilerTests()
Определения EnProfilerTests.c:770
TFResult TestModule()
Определения EnProfilerTests.c:950
float DoEverything()
Определения EnProfilerTests.c:784
TFResult TestClearFlags()
Определения EnProfilerTests.c:881
void ~EnProfilerTests()
Определения EnProfilerTests.c:789
TFResult TestTogglingImmediate()
Определения EnProfilerTests.c:813
TFResult TestFuncCountData()
Определения EnProfilerTests.c:1305
EnProfilerTests TestFramework Sleep2(float timeS)
Определения EnProfilerTests.c:763
TFResult TestClassTimeData()
Определения EnProfilerTests.c:1142
static void TestFuncCountDataHelperStatic()
Определения EnProfilerTests.c:1516
float StringFormat()
Определения EnProfilerTests.c:1481
TFResult TestClassCountData()
Определения EnProfilerTests.c:1190
TFResult TestAddFlags()
Определения EnProfilerTests.c:918
bool m_bWasProfilerEnabled
Remember this, so we can restore the previous state before the test!
Определения EnProfilerTests.c:765
TFResult TestFuncTimeData()
Определения EnProfilerTests.c:1242
TFResult TestSetFlags()
Определения EnProfilerTests.c:828
TFResult TestToggling()
Определения EnProfilerTests.c:798
string Type
Определения JsonDataContaminatedArea.c:11
void TestFramework()
Определения TestFramework.c:217
TFResult NTFR(TFR result)
Определения TestFramework.c:273
bool Assert(bool condition)
Определения TestFramework.c:262
void TFResult(TFR result)
Определения TestFramework.c:12
TFR
Определения TestFramework.c:2
void AddInitTest(string test)
Определения TestFramework.c:249
TFResult BTFR(bool result)
Определения TestFramework.c:278
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()
ScriptModule GameScript
Определения Game.c:12
static void TFLog(string message=LOG_DEFAULT, TestFramework caller=null, string function="")
Определения Debug.c:177
Определения Debug.c:2
Set of methods for accessing script profiling data.
Определения EnProfiler.c:73
static int GetEnumSize(typename e)
Return amount of values in enum.
Определения EnConvert.c:623
static int GetEnumValue(typename e, int idx)
Return the nth value in the enum.
Определения EnConvert.c:634
static int StringToEnum(typename e, string enumName)
Return enum value from string name.
Определения EnConvert.c:612
Определения EnConvert.c:590
static proto native ErrorModuleHandler GetInstance()
Gets the EMH Instance.
The error handler itself, for managing and distributing errors to modules Manages the ErrorHandlerMod...
Определения ErrorModuleHandler.c:29
Определения EnMath.c:7
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
ErrorExSeverity
Определения EnDebug.c:62
enum ShapeType ErrorEx
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
Определения EnProfiler.c:58
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.
Определения EnProfiler.c:138
static bool IsEnabledC()
Return if script profiling is actually turned on inside of the script context.
Определения EnProfiler.c:152
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.
Определения EnProfiler.c:9
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.
Определения EnProfiler.c:22
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.
Определения EnProfiler.c:745
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.