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

◆ TestClassTimeData()

TFResult Sleep2::TestClassTimeData ( )

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

1143{
1146
1147 //---------------------------------------------------------------------------
1148 // Ctor - Decides the tests to run
1149 //---------------------------------------------------------------------------
1150 void EnProfilerTests()
1151 {
1153
1154 AddInitTest("TestToggling");
1155 AddInitTest("TestTogglingImmediate");
1156 AddInitTest("TestSetFlags");
1157 AddInitTest("TestClearFlags");
1158 AddInitTest("TestAddFlags");
1159 AddInitTest("TestModule");
1160 AddInitTest("TestClassTimeData");
1161 AddInitTest("TestClassCountData");
1162 AddInitTest("TestFuncTimeData");
1163 AddInitTest("TestFuncCountData");
1164 }
1165
1166 //---------------------------------------------------------------------------
1167 // Dtor
1168 //---------------------------------------------------------------------------
1169 void ~EnProfilerTests()
1170 {
1172 }
1173
1174 //---------------------------------------------------------------------------
1175 // Tests
1176 //---------------------------------------------------------------------------
1177 // Test toggling state
1179 {
1180 bool currentlyEnabled = EnProfiler.IsEnabledP();
1181 EnProfiler.Enable(!currentlyEnabled);
1182 if (Assert(currentlyEnabled != EnProfiler.IsEnabledP()))
1183 {
1184 EnProfiler.Enable(currentlyEnabled);
1185 return BTFR(Assert(currentlyEnabled == EnProfiler.IsEnabledP()));
1186 }
1187
1188 return NTFR(TFR.FAIL);
1189 }
1190
1191 //---------------------------------------------------------------------------
1192 // Test toggling immediate state
1194 {
1195 bool currentlyEnabled = EnProfiler.IsEnabledC();
1196 EnProfiler.Enable(!currentlyEnabled, true);
1197 if (Assert(currentlyEnabled != EnProfiler.IsEnabledC()))
1198 {
1199 EnProfiler.Enable(currentlyEnabled, true);
1200 return BTFR(Assert(currentlyEnabled == EnProfiler.IsEnabledC()));
1201 }
1202
1203 return NTFR(TFR.FAIL);
1204 }
1205
1206 //---------------------------------------------------------------------------
1207 // Test SetFlags/GetFlags
1209 {
1210 int currentFlags = EnProfiler.GetFlags();
1211
1212 for (int i = 0; i < EnumTools.GetEnumSize(EnProfilerFlags); ++i)
1213 {
1214 int flags = EnumTools.GetEnumValue(EnProfilerFlags, i);
1215 EnProfiler.SetFlags(flags);
1216
1217 if (!Assert(EnProfiler.GetFlags() == flags))
1218 {
1219 EnProfiler.SetFlags(currentFlags);
1220 return NTFR(TFR.FAIL);
1221 }
1222
1223 for (int j = 0; j < EnumTools.GetEnumSize(EnProfilerFlags); ++j)
1224 {
1226 EnProfiler.SetFlags(flags);
1227
1228 if (!Assert(EnProfiler.GetFlags() == flags))
1229 {
1230 EnProfiler.SetFlags(currentFlags);
1231 return NTFR(TFR.FAIL);
1232 }
1233 }
1234 }
1235
1236 // Let's test some bogus
1237 EnProfiler.SetFlags(-333);
1238 int bogusFlags = EnProfiler.GetFlags();
1239 bogusFlags &= ~EnProfilerFlags.ALL;
1240 if (!Assert(bogusFlags == 0))
1241 {
1242 EnProfiler.SetFlags(currentFlags);
1243 return NTFR(TFR.FAIL);
1244 }
1245
1246 bogusFlags = EnProfiler.SetFlags(6003);
1247 bogusFlags &= ~EnProfilerFlags.ALL;
1248 if (!Assert(bogusFlags == 0))
1249 {
1250 EnProfiler.SetFlags(currentFlags);
1251 return NTFR(TFR.FAIL);
1252 }
1253
1254 // Reset
1255 EnProfiler.SetFlags(currentFlags);
1256 return NTFR(TFR.SUCCESS);
1257 }
1258
1259 //---------------------------------------------------------------------------
1260 // Test removing of flags
1262 {
1263 int currentFlags = EnProfiler.GetFlags();
1264
1266
1268 {
1269 EnProfiler.SetFlags(currentFlags);
1270 return NTFR(TFR.FAIL);
1271 }
1272
1275
1276 if (!Assert(EnProfiler.GetFlags() == EnProfilerFlags.NONE))
1277 {
1278 EnProfiler.SetFlags(currentFlags);
1279 return NTFR(TFR.FAIL);
1280 }
1281
1284
1285 if (!Assert(EnProfiler.GetFlags() == EnProfilerFlags.NONE))
1286 {
1287 EnProfiler.SetFlags(currentFlags);
1288 return NTFR(TFR.FAIL);
1289 }
1290
1291 // Reset
1292 EnProfiler.SetFlags(currentFlags);
1293 return NTFR(TFR.SUCCESS);
1294 }
1295
1296 //---------------------------------------------------------------------------
1297 // Test adding of flags
1299 {
1300 int currentFlags = EnProfiler.GetFlags();
1301
1303
1304 // Return should match resulting flags
1306 {
1307 EnProfiler.SetFlags(currentFlags);
1308 return NTFR(TFR.FAIL);
1309 }
1310
1311 if (!Assert(EnProfiler.GetFlags() == EnProfilerFlags.RESET))
1312 {
1313 EnProfiler.SetFlags(currentFlags);
1314 return NTFR(TFR.FAIL);
1315 }
1316
1317 if (!Assert(EnProfiler.AddFlags(EnProfilerFlags.RECURSIVE) == (EnProfilerFlags.RESET | EnProfilerFlags.RECURSIVE)))
1318 {
1319 EnProfiler.SetFlags(currentFlags);
1320 return NTFR(TFR.FAIL);
1321 }
1322
1323 // Reset
1324 EnProfiler.SetFlags(currentFlags);
1325 return NTFR(TFR.SUCCESS);
1326 }
1327
1328 //---------------------------------------------------------------------------
1329 // Test module
1331 {
1332 // File lives in Game, use it while testing
1333 const EnProfilerModule eptModule = EnProfilerModule.GAME;
1334
1335 // This was added at the same time as this API, so check if it works as well
1336 string nameOfCurrentModule = Type().GetModule();
1337 if (!Assert(nameOfCurrentModule != ""))
1338 {
1339 return NTFR(TFR.FAIL);
1340 }
1341
1342 // We know we are in Game, so use it as a test
1343 EnProfilerModule currentModule;
1344 if (!Assert(EnProfiler.NameToModule(nameOfCurrentModule, currentModule)))
1345 {
1346 return NTFR(TFR.FAIL);
1347 }
1348
1349 if (!Assert(currentModule == eptModule))
1350 {
1351 return NTFR(TFR.FAIL);
1352 }
1353
1354 // Test if setting and getting works
1355 EnProfilerModule currentlyProfiledModule = EnProfiler.GetModule();
1356 EnProfiler.SetModule(eptModule);
1357
1358 if (!Assert(EnProfiler.GetModule() == eptModule))
1359 {
1360 EnProfiler.SetModule(currentlyProfiledModule);
1361 return NTFR(TFR.FAIL);
1362 }
1363
1364 // Data to restore
1365 int currentFlags = EnProfiler.GetFlags();
1366 bool wasEnabled = EnProfiler.RequestImmediateData();
1367
1368 // Make sure we are only profiling Game and that the data is clean
1369 // Only valid for the Get...Per... methods, as they need to be sorted
1371
1372 // GetTickTime() returns in seconds, so gather the results in seconds too
1373 int resolution = EnProfiler.GetTimeResolution();
1375
1376 // Time to sleeb
1377 float previousTime = EnProfiler.GetTimeOfFunc("Sleep", Type(), true);
1378 float timeSlept = Sleep(0.3);
1379 float postTime = EnProfiler.GetTimeOfFunc("Sleep", Type(), true);
1380 float diff = postTime - previousTime - timeSlept;
1381
1382 // Restore
1383 EnProfiler.SetTimeResolution(resolution);
1384
1385 // We called the function, so it must have some time
1386 if (!Assert(postTime > 0))
1387 {
1388 EnProfiler.SetFlags(currentFlags);
1389
1390 if (!wasEnabled)
1391 EnProfiler.Enable(false, true);
1392
1393 EnProfiler.SetModule(currentlyProfiledModule);
1394
1395 return NTFR(TFR.FAIL);
1396 }
1397
1398 if (!Assert(diff < 0.00001))
1399 {
1400 EnProfiler.SetFlags(currentFlags);
1401
1402 if (!wasEnabled)
1403 EnProfiler.Enable(false, true);
1404
1405 EnProfiler.SetModule(currentlyProfiledModule);
1406
1407 return NTFR(TFR.FAIL);
1408 }
1409
1410 // Clean the session
1412
1413 // Something from a different module should not get sorted, so just fire something from a different module
1414 for (int i = 0; i < 1000; ++i)
1415 {
1416 EnumTools.StringToEnum(EnProfilerModule, "MISSION_CUSTOM");
1417 }
1418
1419 // Sort and gather the data and validate if it is correct
1421 array<ref EnProfilerTimeFuncPair> timePerFunc = {};
1422 EnProfiler.GetTimePerFunc(timePerFunc);
1423
1424 Debug.TFLog("Game fncs:", this, "TestModule");
1425
1426 int funcCount = timePerFunc.Count();
1427 for (int j = 0; j < funcCount; ++j)
1428 {
1429 EnProfilerTimeFuncPair tfp = timePerFunc[j];
1430 Debug.TFLog(string.Format(" time: %1 | fnc: %2", tfp.param1, tfp.param2), this, "TestModule");
1431 // We are currently profiling Game, so this Core function shouldn't be present
1432 if (!Assert(tfp.param2 != "EnumTools::StringToEnum"))
1433 {
1434 EnProfiler.SetFlags(currentFlags);
1435
1436 if (!wasEnabled)
1437 EnProfiler.Enable(false, true);
1438
1439 EnProfiler.SetModule(currentlyProfiledModule);
1440
1441 return NTFR(TFR.FAIL);
1442 }
1443 }
1444
1445 array<ref EnProfilerTimeClassPair> timePerClass = {};
1446 EnProfiler.GetTimePerClass(timePerClass);
1447
1448 int classCount = timePerClass.Count();
1449 for (int k = 0; k < classCount; ++k)
1450 {
1451 typename type = timePerClass[k].param2;
1452 EnProfilerModule classModule;
1453 if (!Assert(EnProfiler.NameToModule(type.GetModule(), classModule)))
1454 {
1455 EnProfiler.SetFlags(currentFlags);
1456
1457 if (!wasEnabled)
1458 EnProfiler.Enable(false, true);
1459
1460 EnProfiler.SetModule(currentlyProfiledModule);
1461
1462 return NTFR(TFR.FAIL);
1463 }
1464
1465 // Only classes from Game should be present
1466 if (!Assert(classModule == eptModule))
1467 {
1468 EnProfiler.SetFlags(currentFlags);
1469
1470 if (!wasEnabled)
1471 EnProfiler.Enable(false, true);
1472
1473 EnProfiler.SetModule(currentlyProfiledModule);
1474
1475 return NTFR(TFR.FAIL);
1476 }
1477 }
1478
1479 // Now let's check if we can gather the data of what we called earlier by switching the profiled module without resetting the session
1482 timePerFunc.Clear(); // Let's reuse the array, but the Get...Per... methods only appends to the array, clearing is our responsibility
1483 EnProfiler.GetTimePerFunc(timePerFunc);
1484
1485 bool found = false;
1486
1487 Debug.TFLog("Core fncs:", this, "TestModule");
1488
1489 funcCount = timePerFunc.Count();
1490 for (int l = 0; l < funcCount; ++l)
1491 {
1492 EnProfilerTimeFuncPair tfpc = timePerFunc[l];
1493 Debug.TFLog(string.Format(" time: %1 | fnc: %2", tfpc.param1, tfpc.param2), this, "TestModule");
1494 // We are currently profiling Core, so this Core function should be present
1495 if (tfpc.param2 == "EnumTools::StringToEnum")
1496 {
1497 found = true;
1498 break;
1499 }
1500 }
1501
1502 Assert(found);
1503
1504 // Test some bogus
1506 EnProfiler.SetModule(-333);
1507 bool success = Assert(EnProfiler.GetModule() == mod);
1508 EnProfiler.SetModule(6003);
1509 success &= Assert(EnProfiler.GetModule() == mod);
1510
1511 EnProfiler.SetFlags(currentFlags);
1512 EnProfiler.SetModule(currentlyProfiledModule);
1513
1514 if (!wasEnabled)
1515 EnProfiler.Enable(false, true);
1516
1517 return BTFR(success && found);
1518 }
1519
1520 //---------------------------------------------------------------------------
1521 // Test to see if class time data is correct
1523 {
1524 // We should restore this when done
1525 int resolution = EnProfiler.GetTimeResolution();
1526 bool wasEnabled = EnProfiler.RequestImmediateData();
1527
1528 // GetTickTime() returns in seconds, so gather the results in seconds too
1530
1531 // Create the classes
1532 EPTHelperClass clss = new EPTHelperClass();
1533
1534 // Time to stress
1535 float previousTime = EnProfiler.GetTimeOfClass(clss.Type(), true);
1536 float timeStressed = clss.DoEverything();
1537 float postTime = EnProfiler.GetTimeOfClass(clss.Type(), true);
1538 float postTimeStatic = EnProfiler.GetTimeOfClass(StaticGetType(EPTHelperClass), true);
1539 float timeProfiled = postTime - previousTime;
1540 float diff = Math.AbsFloat(timeProfiled - timeStressed);
1541
1542 Debug.TFLog(string.Format("Profiling result: stressed: %1 | profiled: %2 | diff: %3", timeStressed, timeProfiled, diff), this, "TestClassTimeData");
1543
1544 // Restore
1545 EnProfiler.SetTimeResolution(resolution);
1546 if (!wasEnabled)
1547 EnProfiler.Enable(false, true);
1548
1549 // We called the function, so it must have some time
1550 if (!Assert(postTime > 0))
1551 {
1552 return NTFR(TFR.FAIL);
1553 }
1554
1555 if (!Assert(postTime == postTimeStatic))
1556 {
1557 return NTFR(TFR.FAIL);
1558 }
1559
1560 if (!Assert(diff < 0.001))
1561 {
1562 return NTFR(TFR.FAIL);
1563 }
1564
1565 return NTFR(TFR.SUCCESS);
1566 }
1567
1568 //---------------------------------------------------------------------------
1569 // Test to see if class count data is correct
1571 {
1572 const int allocAmount = 9;
1573 const int releaseAmount = 6;
1574 int remainingAmount = allocAmount - releaseAmount;
1575
1576 // We should restore this when done
1577 bool wasEnabled = EnProfiler.RequestImmediateData();
1578
1579 // Time to test
1580 int previousAlloc = EnProfiler.GetAllocationsOfClass(StaticGetType(EPTHelperClass), true);
1581 int previousInstances = EnProfiler.GetInstancesOfClass(StaticGetType(EPTHelperClass), true);
1582
1583 array<ref EPTHelperClass> instanceArr = {};
1584 for (int i = 0; i < allocAmount; ++i)
1585 {
1586 instanceArr.Insert(new EPTHelperClass());
1587 }
1588
1589 for (int j = 0; j < releaseAmount; ++j)
1590 {
1591 delete instanceArr[j];
1592 }
1593
1594 int postAlloc = EnProfiler.GetAllocationsOfClass(StaticGetType(EPTHelperClass), true);
1595 int postInstances = EnProfiler.GetInstancesOfClass(StaticGetType(EPTHelperClass), true);
1596
1597 int alloced = postAlloc - previousAlloc;
1598 int instances = postInstances - previousInstances;
1599
1600 Debug.TFLog(string.Format("Profiling result: alloc: %1 | instances: %2", alloced, instances), this, "TestClassCountData");
1601
1602 // Restore
1603 if (!wasEnabled)
1604 EnProfiler.Enable(false, true);
1605
1606 // Time to check
1607 if (!Assert(alloced == allocAmount))
1608 {
1609 return NTFR(TFR.FAIL);
1610 }
1611
1612 if (!Assert(instances == remainingAmount))
1613 {
1614 return NTFR(TFR.FAIL);
1615 }
1616
1617 return NTFR(TFR.SUCCESS);
1618 }
1619
1620 //---------------------------------------------------------------------------
1621 // Test to see if func time data is correct
1623 {
1624 // We should restore this when done
1625 int resolution = EnProfiler.GetTimeResolution();
1626 bool wasEnabled = EnProfiler.RequestImmediateData();
1627
1628 // GetTickTime() returns in seconds, so gather the results in seconds too
1630
1631 // Time to stress
1632 float previousTime = EnProfiler.GetTimeOfFunc("StringFormat", Type(), true);
1633 float timeStressed = StringFormat();
1634 float postTime = EnProfiler.GetTimeOfFunc("StringFormat", Type(), true);
1635 float timeProfiled = postTime - previousTime;
1636 float diff = Math.AbsFloat(timeProfiled - timeStressed);
1637
1638 float previousTime2 = EnProfiler.GetTimeOfFunc("StringConcat", Type(), true);
1639 float timeStressed2 = StringConcat();
1640 float postTime2 = EnProfiler.GetTimeOfFunc("StringConcat", Type(), true);
1641 float timeProfiled2 = postTime2 - previousTime2;
1642 float diff2 = Math.AbsFloat(timeProfiled2 - timeStressed2);
1643
1644 Debug.TFLog(string.Format("Profiling result: StringFormat: %1 | StringConcat: %2", timeProfiled, timeProfiled2), this, "TestFuncTimeData");
1645
1646 // Restore
1647 EnProfiler.SetTimeResolution(resolution);
1648 if (!wasEnabled)
1649 {
1650 EnProfiler.Enable(false, true);
1651 }
1652
1653 // We called the function, so it must have some time
1654 if (!Assert(postTime > 0))
1655 {
1656 return NTFR(TFR.FAIL);
1657 }
1658
1659 if (!Assert(diff < 0.001))
1660 {
1661 return NTFR(TFR.FAIL);
1662 }
1663
1664 if (!Assert(postTime2 > 0))
1665 {
1666 return NTFR(TFR.FAIL);
1667 }
1668
1669 if (!Assert(diff2 < 0.001))
1670 {
1671 return NTFR(TFR.FAIL);
1672 }
1673
1674 // I know that string.Format is faster than additive concatenation
1675 if (!Assert(timeProfiled < timeProfiled2))
1676 {
1677 return NTFR(TFR.FAIL);
1678 }
1679
1680 return NTFR(TFR.SUCCESS);
1681 }
1682
1683 //---------------------------------------------------------------------------
1684 // Test to see if func count data is correct
1686 {
1687 // We should restore this when done
1688 bool wasEnabled = EnProfiler.RequestImmediateData();
1689
1690 // Time to count
1691
1692 // - CallFunction
1693 int previousCountCF = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
1694 GetGame().GameScript.CallFunction(this, "TestFuncCountDataHelper", null, 0);
1695 int postCountCF = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
1696
1697 int callCountCF = postCountCF - previousCountCF;
1698
1699 // - CallFunctionParams
1700 int previousCountCFP = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
1701 GetGame().GameScript.CallFunctionParams(this, "TestFuncCountDataHelper", null, null);
1702 int postCountCFP = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
1703
1704 int callCountCFP = postCountCFP - previousCountCFP;
1705
1706 // - Regular call
1707 int previousCountRG = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
1709 int postCountRG = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
1710
1711 int callCountRG = postCountRG - previousCountRG;
1712
1713 // - Call
1714 int previousCountC = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
1715 GetGame().GameScript.Call(this, "TestFuncCountDataHelper", 0);
1716 int postCountC = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
1717
1718 int callCountC = postCountC - previousCountC;
1719
1720 // - Garbage
1721 int callCountNon = EnProfiler.GetCountOfFunc("Non Existing Method", Type(), true);
1722
1723 // - Static
1724 int previousCountS = EnProfiler.GetCountOfFunc("TestFuncCountDataHelperStatic", Type(), true);
1726 int postCountS = EnProfiler.GetCountOfFunc("TestFuncCountDataHelperStatic", Type(), true);
1727
1728 int callCountS = postCountS - previousCountS;
1729
1730 // - Global
1731 int previousCountG = EnProfiler.GetCountOfFuncG("GetDayZGame", true);
1732 GetDayZGame();
1733 int postCountG = EnProfiler.GetCountOfFuncG("GetDayZGame", true);
1734
1735 int callCountG = postCountG - previousCountG;
1736
1737 // - Global proto
1738 // Not tracked, so don't need to compare before and after, should always be 0
1739 ErrorEx("Testing global proto call", ErrorExSeverity.INFO);
1740 int callCountGP = EnProfiler.GetCountOfFuncG("ErrorEx", true);
1741
1742 // - Static proto
1743 // Not tracked, so don't need to compare before and after, should always be 0
1744 int callCountSP = EnProfiler.GetCountOfFunc("GetCountOfFunc", StaticGetType(EnProfiler), true);
1745
1746 // - proto
1747 // Not tracked, so don't need to compare before and after, should always be 0
1748 GetGame().GetHostName();
1749 int callCountP = EnProfiler.GetCountOfFunc("GetHostName", GetGame().Type(), true);
1750
1751 // - proto native
1752 // Not tracked, so don't need to compare before and after, should always be 0
1753 GetGame().IsServer();
1754 int callCountPN = EnProfiler.GetCountOfFunc("IsServer", GetGame().Type(), true);
1755
1756 // - static proto native
1757 // Not tracked, so don't need to compare before and after, should always be 0
1759 int callCountSPN = EnProfiler.GetCountOfFunc("GetInstance", StaticGetType(ErrorModuleHandler), true);
1760
1761 // Restore
1762 if (!wasEnabled)
1763 {
1764 EnProfiler.Enable(false, true);
1765 }
1766
1767 // Do the checks
1768
1769 // - CallFunction
1770 if (!Assert(callCountCF == 1))
1771 {
1772 return NTFR(TFR.FAIL);
1773 }
1774
1775 // - CallFunctionParams
1776 if (!Assert(callCountCFP == 1))
1777 {
1778 return NTFR(TFR.FAIL);
1779 }
1780
1781 // - Regular call
1782 if (!Assert(callCountRG == 1))
1783 {
1784 return NTFR(TFR.FAIL);
1785 }
1786
1787 // - Call
1788 if (!Assert(callCountC == 1))
1789 {
1790 return NTFR(TFR.FAIL);
1791 }
1792
1793 // - Garbage
1794 if (!Assert(callCountNon == -1))
1795 {
1796 return NTFR(TFR.FAIL);
1797 }
1798
1799 // - Static
1800 if (!Assert(callCountS == 1))
1801 {
1802 return NTFR(TFR.FAIL);
1803 }
1804
1805 // - Global
1806 if (!Assert(callCountG == 1))
1807 {
1808 return NTFR(TFR.FAIL);
1809 }
1810
1811 // - Global proto
1812 if (!Assert(callCountGP == 0))
1813 {
1814 return NTFR(TFR.FAIL);
1815 }
1816
1817 // - Static proto
1818 if (!Assert(callCountSP == 0))
1819 {
1820 return NTFR(TFR.FAIL);
1821 }
1822
1823 // - proto
1824 if (!Assert(callCountP == 0))
1825 {
1826 return NTFR(TFR.FAIL);
1827 }
1828
1829 // - proto native
1830 if (!Assert(callCountPN == 0))
1831 {
1832 return NTFR(TFR.FAIL);
1833 }
1834
1835 // - static proto native
1836 if (!Assert(callCountSPN == 0))
1837 {
1838 return NTFR(TFR.FAIL);
1839 }
1840
1841 return NTFR(TFR.SUCCESS);
1842 }
1843
1844 //---------------------------------------------------------------------------
1845 // Helpers
1846 //---------------------------------------------------------------------------
1847 // Snore
1848 float Sleep(float timeS)
1849 {
1850 float startTime = GetGame().GetTickTime();
1851 while (GetGame().GetTickTime() - startTime < timeS)
1852 {
1853 // Zzz
1854 }
1855
1856 return GetGame().GetTickTime() - startTime;
1857 }
1858
1859 //---------------------------------------------------------------------------
1860 // Example stress method
1861 float StringFormat()
1862 {
1863 float startTime = GetGame().GetTickTime();
1864
1865 for (int i = 0; i < 1000; ++i)
1866 {
1867 string example = string.Format("This %1 is %2 just %3 an %4 example %5", i, Type(), this, startTime, "lorem ipsum 1 2 3");
1868 }
1869
1870 return GetGame().GetTickTime() - startTime;
1871 }
1872
1873 //---------------------------------------------------------------------------
1874 // Example stress method 2
1875 float StringConcat()
1876 {
1877 float startTime = GetGame().GetTickTime();
1878
1879 for (int i = 0; i < 1000; ++i)
1880 {
1881 string example = "This " + i + " is " + Type() + " just " + this + " an " + startTime + " example " + "lorem ipsum 1 2 3";
1882 }
1883
1884 return GetGame().GetTickTime() - startTime;
1885 }
1886
1887 //---------------------------------------------------------------------------
1888 // To make sure it is only ever called in that test
1890 {
1891 int dummy = 3;
1892 }
1893
1894 //---------------------------------------------------------------------------
1895 // To make sure it is only ever called in that test
1896 static void TestFuncCountDataHelperStatic()
1897 {
1898 int dummy = 3;
1899 }
1900}
1901
1902class EPTHelperClass
1903{
1904 float Sleep2(float timeS)
1905 {
1906 float startTime = GetGame().GetTickTime();
1907 while (GetGame().GetTickTime() - startTime < timeS)
1908 {
1909 // Zzz
1910 }
1911
1912 return GetGame().GetTickTime() - startTime;
1913 }
1914 float SleepAgain(float timeS)
1915 {
1916 float startTime = GetGame().GetTickTime();
1917 while (GetGame().GetTickTime() - startTime < timeS)
1918 {
1919 // Zzz
1920 }
1921
1922 return GetGame().GetTickTime() - startTime;
1923 }
1924
1925 float DoEverything()
1926 {
1927 float startTime = GetGame().GetTickTime();
1928
1929 Sleep2(3);
1930 SleepAgain(3);
1931
1932 return GetGame().GetTickTime() - startTime;
1933 }
1934}
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.