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

◆ Sleep()

float Sleep2::Sleep ( float timeS)

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

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