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

◆ TestSetFlags()

TFResult Sleep2::TestSetFlags ( )

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

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