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

◆ TestFuncCountData()

TFResult Sleep2::TestFuncCountData ( )

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

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