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

◆ TestFuncTimeData()

TFResult Sleep2::TestFuncTimeData ( )

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

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