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

◆ TestFuncCountDataHelperStatic()

static void Sleep2::TestFuncCountDataHelperStatic ( )
static

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

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