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

◆ StringConcat()

float Sleep2::StringConcat ( )

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

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