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

◆ TestFuncCountDataHelper()

void Sleep2::TestFuncCountDataHelper ( )

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

1510{
1513
1514 //---------------------------------------------------------------------------
1515 // Ctor - Decides the tests to run
1516 //---------------------------------------------------------------------------
1517 void EnProfilerTests()
1518 {
1520
1521 AddInitTest("TestToggling");
1522 AddInitTest("TestTogglingImmediate");
1523 AddInitTest("TestSetFlags");
1524 AddInitTest("TestClearFlags");
1525 AddInitTest("TestAddFlags");
1526 AddInitTest("TestModule");
1527 AddInitTest("TestClassTimeData");
1528 AddInitTest("TestClassCountData");
1529 AddInitTest("TestFuncTimeData");
1530 AddInitTest("TestFuncCountData");
1531 }
1532
1533 //---------------------------------------------------------------------------
1534 // Dtor
1535 //---------------------------------------------------------------------------
1536 void ~EnProfilerTests()
1537 {
1539 }
1540
1541 //---------------------------------------------------------------------------
1542 // Tests
1543 //---------------------------------------------------------------------------
1544 // Test toggling state
1546 {
1547 bool currentlyEnabled = EnProfiler.IsEnabledP();
1548 EnProfiler.Enable(!currentlyEnabled);
1549 if (Assert(currentlyEnabled != EnProfiler.IsEnabledP()))
1550 {
1551 EnProfiler.Enable(currentlyEnabled);
1552 return BTFR(Assert(currentlyEnabled == EnProfiler.IsEnabledP()));
1553 }
1554
1555 return NTFR(TFR.FAIL);
1556 }
1557
1558 //---------------------------------------------------------------------------
1559 // Test toggling immediate state
1561 {
1562 bool currentlyEnabled = EnProfiler.IsEnabledC();
1563 EnProfiler.Enable(!currentlyEnabled, true);
1564 if (Assert(currentlyEnabled != EnProfiler.IsEnabledC()))
1565 {
1566 EnProfiler.Enable(currentlyEnabled, true);
1567 return BTFR(Assert(currentlyEnabled == EnProfiler.IsEnabledC()));
1568 }
1569
1570 return NTFR(TFR.FAIL);
1571 }
1572
1573 //---------------------------------------------------------------------------
1574 // Test SetFlags/GetFlags
1576 {
1577 int currentFlags = EnProfiler.GetFlags();
1578
1579 for (int i = 0; i < EnumTools.GetEnumSize(EnProfilerFlags); ++i)
1580 {
1581 int flags = EnumTools.GetEnumValue(EnProfilerFlags, i);
1582 EnProfiler.SetFlags(flags);
1583
1584 if (!Assert(EnProfiler.GetFlags() == flags))
1585 {
1586 EnProfiler.SetFlags(currentFlags);
1587 return NTFR(TFR.FAIL);
1588 }
1589
1590 for (int j = 0; j < EnumTools.GetEnumSize(EnProfilerFlags); ++j)
1591 {
1593 EnProfiler.SetFlags(flags);
1594
1595 if (!Assert(EnProfiler.GetFlags() == flags))
1596 {
1597 EnProfiler.SetFlags(currentFlags);
1598 return NTFR(TFR.FAIL);
1599 }
1600 }
1601 }
1602
1603 // Let's test some bogus
1604 EnProfiler.SetFlags(-333);
1605 int bogusFlags = EnProfiler.GetFlags();
1606 bogusFlags &= ~EnProfilerFlags.ALL;
1607 if (!Assert(bogusFlags == 0))
1608 {
1609 EnProfiler.SetFlags(currentFlags);
1610 return NTFR(TFR.FAIL);
1611 }
1612
1613 bogusFlags = EnProfiler.SetFlags(6003);
1614 bogusFlags &= ~EnProfilerFlags.ALL;
1615 if (!Assert(bogusFlags == 0))
1616 {
1617 EnProfiler.SetFlags(currentFlags);
1618 return NTFR(TFR.FAIL);
1619 }
1620
1621 // Reset
1622 EnProfiler.SetFlags(currentFlags);
1623 return NTFR(TFR.SUCCESS);
1624 }
1625
1626 //---------------------------------------------------------------------------
1627 // Test removing of flags
1629 {
1630 int currentFlags = EnProfiler.GetFlags();
1631
1633
1635 {
1636 EnProfiler.SetFlags(currentFlags);
1637 return NTFR(TFR.FAIL);
1638 }
1639
1642
1643 if (!Assert(EnProfiler.GetFlags() == EnProfilerFlags.NONE))
1644 {
1645 EnProfiler.SetFlags(currentFlags);
1646 return NTFR(TFR.FAIL);
1647 }
1648
1651
1652 if (!Assert(EnProfiler.GetFlags() == EnProfilerFlags.NONE))
1653 {
1654 EnProfiler.SetFlags(currentFlags);
1655 return NTFR(TFR.FAIL);
1656 }
1657
1658 // Reset
1659 EnProfiler.SetFlags(currentFlags);
1660 return NTFR(TFR.SUCCESS);
1661 }
1662
1663 //---------------------------------------------------------------------------
1664 // Test adding of flags
1666 {
1667 int currentFlags = EnProfiler.GetFlags();
1668
1670
1671 // Return should match resulting flags
1673 {
1674 EnProfiler.SetFlags(currentFlags);
1675 return NTFR(TFR.FAIL);
1676 }
1677
1678 if (!Assert(EnProfiler.GetFlags() == EnProfilerFlags.RESET))
1679 {
1680 EnProfiler.SetFlags(currentFlags);
1681 return NTFR(TFR.FAIL);
1682 }
1683
1684 if (!Assert(EnProfiler.AddFlags(EnProfilerFlags.RECURSIVE) == (EnProfilerFlags.RESET | EnProfilerFlags.RECURSIVE)))
1685 {
1686 EnProfiler.SetFlags(currentFlags);
1687 return NTFR(TFR.FAIL);
1688 }
1689
1690 // Reset
1691 EnProfiler.SetFlags(currentFlags);
1692 return NTFR(TFR.SUCCESS);
1693 }
1694
1695 //---------------------------------------------------------------------------
1696 // Test module
1698 {
1699 // File lives in Game, use it while testing
1700 const EnProfilerModule eptModule = EnProfilerModule.GAME;
1701
1702 // This was added at the same time as this API, so check if it works as well
1703 string nameOfCurrentModule = Type().GetModule();
1704 if (!Assert(nameOfCurrentModule != ""))
1705 {
1706 return NTFR(TFR.FAIL);
1707 }
1708
1709 // We know we are in Game, so use it as a test
1710 EnProfilerModule currentModule;
1711 if (!Assert(EnProfiler.NameToModule(nameOfCurrentModule, currentModule)))
1712 {
1713 return NTFR(TFR.FAIL);
1714 }
1715
1716 if (!Assert(currentModule == eptModule))
1717 {
1718 return NTFR(TFR.FAIL);
1719 }
1720
1721 // Test if setting and getting works
1722 EnProfilerModule currentlyProfiledModule = EnProfiler.GetModule();
1723 EnProfiler.SetModule(eptModule);
1724
1725 if (!Assert(EnProfiler.GetModule() == eptModule))
1726 {
1727 EnProfiler.SetModule(currentlyProfiledModule);
1728 return NTFR(TFR.FAIL);
1729 }
1730
1731 // Data to restore
1732 int currentFlags = EnProfiler.GetFlags();
1733 bool wasEnabled = EnProfiler.RequestImmediateData();
1734
1735 // Make sure we are only profiling Game and that the data is clean
1736 // Only valid for the Get...Per... methods, as they need to be sorted
1738
1739 // GetTickTime() returns in seconds, so gather the results in seconds too
1740 int resolution = EnProfiler.GetTimeResolution();
1742
1743 // Time to sleeb
1744 float previousTime = EnProfiler.GetTimeOfFunc("Sleep", Type(), true);
1745 float timeSlept = Sleep(0.3);
1746 float postTime = EnProfiler.GetTimeOfFunc("Sleep", Type(), true);
1747 float diff = postTime - previousTime - timeSlept;
1748
1749 // Restore
1750 EnProfiler.SetTimeResolution(resolution);
1751
1752 // We called the function, so it must have some time
1753 if (!Assert(postTime > 0))
1754 {
1755 EnProfiler.SetFlags(currentFlags);
1756
1757 if (!wasEnabled)
1758 EnProfiler.Enable(false, true);
1759
1760 EnProfiler.SetModule(currentlyProfiledModule);
1761
1762 return NTFR(TFR.FAIL);
1763 }
1764
1765 if (!Assert(diff < 0.00001))
1766 {
1767 EnProfiler.SetFlags(currentFlags);
1768
1769 if (!wasEnabled)
1770 EnProfiler.Enable(false, true);
1771
1772 EnProfiler.SetModule(currentlyProfiledModule);
1773
1774 return NTFR(TFR.FAIL);
1775 }
1776
1777 // Clean the session
1779
1780 // Something from a different module should not get sorted, so just fire something from a different module
1781 for (int i = 0; i < 1000; ++i)
1782 {
1783 EnumTools.StringToEnum(EnProfilerModule, "MISSION_CUSTOM");
1784 }
1785
1786 // Sort and gather the data and validate if it is correct
1788 array<ref EnProfilerTimeFuncPair> timePerFunc = {};
1789 EnProfiler.GetTimePerFunc(timePerFunc);
1790
1791 Debug.TFLog("Game fncs:", this, "TestModule");
1792
1793 int funcCount = timePerFunc.Count();
1794 for (int j = 0; j < funcCount; ++j)
1795 {
1796 EnProfilerTimeFuncPair tfp = timePerFunc[j];
1797 Debug.TFLog(string.Format(" time: %1 | fnc: %2", tfp.param1, tfp.param2), this, "TestModule");
1798 // We are currently profiling Game, so this Core function shouldn't be present
1799 if (!Assert(tfp.param2 != "EnumTools::StringToEnum"))
1800 {
1801 EnProfiler.SetFlags(currentFlags);
1802
1803 if (!wasEnabled)
1804 EnProfiler.Enable(false, true);
1805
1806 EnProfiler.SetModule(currentlyProfiledModule);
1807
1808 return NTFR(TFR.FAIL);
1809 }
1810 }
1811
1812 array<ref EnProfilerTimeClassPair> timePerClass = {};
1813 EnProfiler.GetTimePerClass(timePerClass);
1814
1815 int classCount = timePerClass.Count();
1816 for (int k = 0; k < classCount; ++k)
1817 {
1818 typename type = timePerClass[k].param2;
1819 EnProfilerModule classModule;
1820 if (!Assert(EnProfiler.NameToModule(type.GetModule(), classModule)))
1821 {
1822 EnProfiler.SetFlags(currentFlags);
1823
1824 if (!wasEnabled)
1825 EnProfiler.Enable(false, true);
1826
1827 EnProfiler.SetModule(currentlyProfiledModule);
1828
1829 return NTFR(TFR.FAIL);
1830 }
1831
1832 // Only classes from Game should be present
1833 if (!Assert(classModule == eptModule))
1834 {
1835 EnProfiler.SetFlags(currentFlags);
1836
1837 if (!wasEnabled)
1838 EnProfiler.Enable(false, true);
1839
1840 EnProfiler.SetModule(currentlyProfiledModule);
1841
1842 return NTFR(TFR.FAIL);
1843 }
1844 }
1845
1846 // Now let's check if we can gather the data of what we called earlier by switching the profiled module without resetting the session
1849 timePerFunc.Clear(); // Let's reuse the array, but the Get...Per... methods only appends to the array, clearing is our responsibility
1850 EnProfiler.GetTimePerFunc(timePerFunc);
1851
1852 bool found = false;
1853
1854 Debug.TFLog("Core fncs:", this, "TestModule");
1855
1856 funcCount = timePerFunc.Count();
1857 for (int l = 0; l < funcCount; ++l)
1858 {
1859 EnProfilerTimeFuncPair tfpc = timePerFunc[l];
1860 Debug.TFLog(string.Format(" time: %1 | fnc: %2", tfpc.param1, tfpc.param2), this, "TestModule");
1861 // We are currently profiling Core, so this Core function should be present
1862 if (tfpc.param2 == "EnumTools::StringToEnum")
1863 {
1864 found = true;
1865 break;
1866 }
1867 }
1868
1869 Assert(found);
1870
1871 // Test some bogus
1873 EnProfiler.SetModule(-333);
1874 bool success = Assert(EnProfiler.GetModule() == mod);
1875 EnProfiler.SetModule(6003);
1876 success &= Assert(EnProfiler.GetModule() == mod);
1877
1878 EnProfiler.SetFlags(currentFlags);
1879 EnProfiler.SetModule(currentlyProfiledModule);
1880
1881 if (!wasEnabled)
1882 EnProfiler.Enable(false, true);
1883
1884 return BTFR(success && found);
1885 }
1886
1887 //---------------------------------------------------------------------------
1888 // Test to see if class time data is correct
1890 {
1891 // We should restore this when done
1892 int resolution = EnProfiler.GetTimeResolution();
1893 bool wasEnabled = EnProfiler.RequestImmediateData();
1894
1895 // GetTickTime() returns in seconds, so gather the results in seconds too
1897
1898 // Create the classes
1899 EPTHelperClass clss = new EPTHelperClass();
1900
1901 // Time to stress
1902 float previousTime = EnProfiler.GetTimeOfClass(clss.Type(), true);
1903 float timeStressed = clss.DoEverything();
1904 float postTime = EnProfiler.GetTimeOfClass(clss.Type(), true);
1905 float postTimeStatic = EnProfiler.GetTimeOfClass(StaticGetType(EPTHelperClass), true);
1906 float timeProfiled = postTime - previousTime;
1907 float diff = Math.AbsFloat(timeProfiled - timeStressed);
1908
1909 Debug.TFLog(string.Format("Profiling result: stressed: %1 | profiled: %2 | diff: %3", timeStressed, timeProfiled, diff), this, "TestClassTimeData");
1910
1911 // Restore
1912 EnProfiler.SetTimeResolution(resolution);
1913 if (!wasEnabled)
1914 EnProfiler.Enable(false, true);
1915
1916 // We called the function, so it must have some time
1917 if (!Assert(postTime > 0))
1918 {
1919 return NTFR(TFR.FAIL);
1920 }
1921
1922 if (!Assert(postTime == postTimeStatic))
1923 {
1924 return NTFR(TFR.FAIL);
1925 }
1926
1927 if (!Assert(diff < 0.001))
1928 {
1929 return NTFR(TFR.FAIL);
1930 }
1931
1932 return NTFR(TFR.SUCCESS);
1933 }
1934
1935 //---------------------------------------------------------------------------
1936 // Test to see if class count data is correct
1938 {
1939 const int allocAmount = 9;
1940 const int releaseAmount = 6;
1941 int remainingAmount = allocAmount - releaseAmount;
1942
1943 // We should restore this when done
1944 bool wasEnabled = EnProfiler.RequestImmediateData();
1945
1946 // Time to test
1947 int previousAlloc = EnProfiler.GetAllocationsOfClass(StaticGetType(EPTHelperClass), true);
1948 int previousInstances = EnProfiler.GetInstancesOfClass(StaticGetType(EPTHelperClass), true);
1949
1950 array<ref EPTHelperClass> instanceArr = {};
1951 for (int i = 0; i < allocAmount; ++i)
1952 {
1953 instanceArr.Insert(new EPTHelperClass());
1954 }
1955
1956 for (int j = 0; j < releaseAmount; ++j)
1957 {
1958 delete instanceArr[j];
1959 }
1960
1961 int postAlloc = EnProfiler.GetAllocationsOfClass(StaticGetType(EPTHelperClass), true);
1962 int postInstances = EnProfiler.GetInstancesOfClass(StaticGetType(EPTHelperClass), true);
1963
1964 int alloced = postAlloc - previousAlloc;
1965 int instances = postInstances - previousInstances;
1966
1967 Debug.TFLog(string.Format("Profiling result: alloc: %1 | instances: %2", alloced, instances), this, "TestClassCountData");
1968
1969 // Restore
1970 if (!wasEnabled)
1971 EnProfiler.Enable(false, true);
1972
1973 // Time to check
1974 if (!Assert(alloced == allocAmount))
1975 {
1976 return NTFR(TFR.FAIL);
1977 }
1978
1979 if (!Assert(instances == remainingAmount))
1980 {
1981 return NTFR(TFR.FAIL);
1982 }
1983
1984 return NTFR(TFR.SUCCESS);
1985 }
1986
1987 //---------------------------------------------------------------------------
1988 // Test to see if func time data is correct
1990 {
1991 // We should restore this when done
1992 int resolution = EnProfiler.GetTimeResolution();
1993 bool wasEnabled = EnProfiler.RequestImmediateData();
1994
1995 // GetTickTime() returns in seconds, so gather the results in seconds too
1997
1998 // Time to stress
1999 float previousTime = EnProfiler.GetTimeOfFunc("StringFormat", Type(), true);
2000 float timeStressed = StringFormat();
2001 float postTime = EnProfiler.GetTimeOfFunc("StringFormat", Type(), true);
2002 float timeProfiled = postTime - previousTime;
2003 float diff = Math.AbsFloat(timeProfiled - timeStressed);
2004
2005 float previousTime2 = EnProfiler.GetTimeOfFunc("StringConcat", Type(), true);
2006 float timeStressed2 = StringConcat();
2007 float postTime2 = EnProfiler.GetTimeOfFunc("StringConcat", Type(), true);
2008 float timeProfiled2 = postTime2 - previousTime2;
2009 float diff2 = Math.AbsFloat(timeProfiled2 - timeStressed2);
2010
2011 Debug.TFLog(string.Format("Profiling result: StringFormat: %1 | StringConcat: %2", timeProfiled, timeProfiled2), this, "TestFuncTimeData");
2012
2013 // Restore
2014 EnProfiler.SetTimeResolution(resolution);
2015 if (!wasEnabled)
2016 {
2017 EnProfiler.Enable(false, true);
2018 }
2019
2020 // We called the function, so it must have some time
2021 if (!Assert(postTime > 0))
2022 {
2023 return NTFR(TFR.FAIL);
2024 }
2025
2026 if (!Assert(diff < 0.001))
2027 {
2028 return NTFR(TFR.FAIL);
2029 }
2030
2031 if (!Assert(postTime2 > 0))
2032 {
2033 return NTFR(TFR.FAIL);
2034 }
2035
2036 if (!Assert(diff2 < 0.001))
2037 {
2038 return NTFR(TFR.FAIL);
2039 }
2040
2041 // I know that string.Format is faster than additive concatenation
2042 if (!Assert(timeProfiled < timeProfiled2))
2043 {
2044 return NTFR(TFR.FAIL);
2045 }
2046
2047 return NTFR(TFR.SUCCESS);
2048 }
2049
2050 //---------------------------------------------------------------------------
2051 // Test to see if func count data is correct
2053 {
2054 // We should restore this when done
2055 bool wasEnabled = EnProfiler.RequestImmediateData();
2056
2057 // Time to count
2058
2059 // - CallFunction
2060 int previousCountCF = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
2061 GetGame().GameScript.CallFunction(this, "TestFuncCountDataHelper", null, 0);
2062 int postCountCF = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
2063
2064 int callCountCF = postCountCF - previousCountCF;
2065
2066 // - CallFunctionParams
2067 int previousCountCFP = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
2068 GetGame().GameScript.CallFunctionParams(this, "TestFuncCountDataHelper", null, null);
2069 int postCountCFP = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
2070
2071 int callCountCFP = postCountCFP - previousCountCFP;
2072
2073 // - Regular call
2074 int previousCountRG = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
2076 int postCountRG = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
2077
2078 int callCountRG = postCountRG - previousCountRG;
2079
2080 // - Call
2081 int previousCountC = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
2082 GetGame().GameScript.Call(this, "TestFuncCountDataHelper", 0);
2083 int postCountC = EnProfiler.GetCountOfFunc("TestFuncCountDataHelper", Type(), true);
2084
2085 int callCountC = postCountC - previousCountC;
2086
2087 // - Garbage
2088 int callCountNon = EnProfiler.GetCountOfFunc("Non Existing Method", Type(), true);
2089
2090 // - Static
2091 int previousCountS = EnProfiler.GetCountOfFunc("TestFuncCountDataHelperStatic", Type(), true);
2093 int postCountS = EnProfiler.GetCountOfFunc("TestFuncCountDataHelperStatic", Type(), true);
2094
2095 int callCountS = postCountS - previousCountS;
2096
2097 // - Global
2098 int previousCountG = EnProfiler.GetCountOfFuncG("GetDayZGame", true);
2099 GetDayZGame();
2100 int postCountG = EnProfiler.GetCountOfFuncG("GetDayZGame", true);
2101
2102 int callCountG = postCountG - previousCountG;
2103
2104 // - Global proto
2105 // Not tracked, so don't need to compare before and after, should always be 0
2106 ErrorEx("Testing global proto call", ErrorExSeverity.INFO);
2107 int callCountGP = EnProfiler.GetCountOfFuncG("ErrorEx", true);
2108
2109 // - Static proto
2110 // Not tracked, so don't need to compare before and after, should always be 0
2111 int callCountSP = EnProfiler.GetCountOfFunc("GetCountOfFunc", StaticGetType(EnProfiler), true);
2112
2113 // - proto
2114 // Not tracked, so don't need to compare before and after, should always be 0
2115 GetGame().GetHostName();
2116 int callCountP = EnProfiler.GetCountOfFunc("GetHostName", GetGame().Type(), true);
2117
2118 // - proto native
2119 // Not tracked, so don't need to compare before and after, should always be 0
2120 GetGame().IsServer();
2121 int callCountPN = EnProfiler.GetCountOfFunc("IsServer", GetGame().Type(), true);
2122
2123 // - static proto native
2124 // Not tracked, so don't need to compare before and after, should always be 0
2126 int callCountSPN = EnProfiler.GetCountOfFunc("GetInstance", StaticGetType(ErrorModuleHandler), true);
2127
2128 // Restore
2129 if (!wasEnabled)
2130 {
2131 EnProfiler.Enable(false, true);
2132 }
2133
2134 // Do the checks
2135
2136 // - CallFunction
2137 if (!Assert(callCountCF == 1))
2138 {
2139 return NTFR(TFR.FAIL);
2140 }
2141
2142 // - CallFunctionParams
2143 if (!Assert(callCountCFP == 1))
2144 {
2145 return NTFR(TFR.FAIL);
2146 }
2147
2148 // - Regular call
2149 if (!Assert(callCountRG == 1))
2150 {
2151 return NTFR(TFR.FAIL);
2152 }
2153
2154 // - Call
2155 if (!Assert(callCountC == 1))
2156 {
2157 return NTFR(TFR.FAIL);
2158 }
2159
2160 // - Garbage
2161 if (!Assert(callCountNon == -1))
2162 {
2163 return NTFR(TFR.FAIL);
2164 }
2165
2166 // - Static
2167 if (!Assert(callCountS == 1))
2168 {
2169 return NTFR(TFR.FAIL);
2170 }
2171
2172 // - Global
2173 if (!Assert(callCountG == 1))
2174 {
2175 return NTFR(TFR.FAIL);
2176 }
2177
2178 // - Global proto
2179 if (!Assert(callCountGP == 0))
2180 {
2181 return NTFR(TFR.FAIL);
2182 }
2183
2184 // - Static proto
2185 if (!Assert(callCountSP == 0))
2186 {
2187 return NTFR(TFR.FAIL);
2188 }
2189
2190 // - proto
2191 if (!Assert(callCountP == 0))
2192 {
2193 return NTFR(TFR.FAIL);
2194 }
2195
2196 // - proto native
2197 if (!Assert(callCountPN == 0))
2198 {
2199 return NTFR(TFR.FAIL);
2200 }
2201
2202 // - static proto native
2203 if (!Assert(callCountSPN == 0))
2204 {
2205 return NTFR(TFR.FAIL);
2206 }
2207
2208 return NTFR(TFR.SUCCESS);
2209 }
2210
2211 //---------------------------------------------------------------------------
2212 // Helpers
2213 //---------------------------------------------------------------------------
2214 // Snore
2215 float Sleep(float timeS)
2216 {
2217 float startTime = GetGame().GetTickTime();
2218 while (GetGame().GetTickTime() - startTime < timeS)
2219 {
2220 // Zzz
2221 }
2222
2223 return GetGame().GetTickTime() - startTime;
2224 }
2225
2226 //---------------------------------------------------------------------------
2227 // Example stress method
2228 float StringFormat()
2229 {
2230 float startTime = GetGame().GetTickTime();
2231
2232 for (int i = 0; i < 1000; ++i)
2233 {
2234 string example = string.Format("This %1 is %2 just %3 an %4 example %5", i, Type(), this, startTime, "lorem ipsum 1 2 3");
2235 }
2236
2237 return GetGame().GetTickTime() - startTime;
2238 }
2239
2240 //---------------------------------------------------------------------------
2241 // Example stress method 2
2242 float StringConcat()
2243 {
2244 float startTime = GetGame().GetTickTime();
2245
2246 for (int i = 0; i < 1000; ++i)
2247 {
2248 string example = "This " + i + " is " + Type() + " just " + this + " an " + startTime + " example " + "lorem ipsum 1 2 3";
2249 }
2250
2251 return GetGame().GetTickTime() - startTime;
2252 }
2253
2254 //---------------------------------------------------------------------------
2255 // To make sure it is only ever called in that test
2257 {
2258 int dummy = 3;
2259 }
2260
2261 //---------------------------------------------------------------------------
2262 // To make sure it is only ever called in that test
2263 static void TestFuncCountDataHelperStatic()
2264 {
2265 int dummy = 3;
2266 }
2267}
2268
2269class EPTHelperClass
2270{
2271 float Sleep2(float timeS)
2272 {
2273 float startTime = GetGame().GetTickTime();
2274 while (GetGame().GetTickTime() - startTime < timeS)
2275 {
2276 // Zzz
2277 }
2278
2279 return GetGame().GetTickTime() - startTime;
2280 }
2281 float SleepAgain(float timeS)
2282 {
2283 float startTime = GetGame().GetTickTime();
2284 while (GetGame().GetTickTime() - startTime < timeS)
2285 {
2286 // Zzz
2287 }
2288
2289 return GetGame().GetTickTime() - startTime;
2290 }
2291
2292 float DoEverything()
2293 {
2294 float startTime = GetGame().GetTickTime();
2295
2296 Sleep2(3);
2297 SleepAgain(3);
2298
2299 return GetGame().GetTickTime() - startTime;
2300 }
2301}
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.