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

◆ TestTogglingImmediate()

TFResult Sleep2::TestTogglingImmediate ( )

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

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