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

◆ TestClassCountData()

TFResult Sleep2::TestClassCountData ( )

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

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