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

◆ TestModule()

TFResult Sleep2::TestModule ( )

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

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