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

◆ TestClearFlags()

TFResult Sleep2::TestClearFlags ( )

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

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