diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 105d97d..3697f78 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -1083,7 +1083,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1083 | 1083 | ||
1084 | if (!m_PrimObjects[localID].Contains(itemID)) | 1084 | if (!m_PrimObjects[localID].Contains(itemID)) |
1085 | m_PrimObjects[localID].Add(itemID); | 1085 | m_PrimObjects[localID].Add(itemID); |
1086 | |||
1087 | } | 1086 | } |
1088 | 1087 | ||
1089 | if (!m_Assemblies.ContainsKey(assetID)) | 1088 | if (!m_Assemblies.ContainsKey(assetID)) |
@@ -1891,6 +1890,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1891 | } | 1890 | } |
1892 | } | 1891 | } |
1893 | 1892 | ||
1893 | public Dictionary<uint, float> GetObjectScriptsExecutionTimes() | ||
1894 | { | ||
1895 | long tickNow = Util.EnvironmentTickCount(); | ||
1896 | Dictionary<uint, float> topScripts = new Dictionary<uint, float>(); | ||
1897 | |||
1898 | lock (m_Scripts) | ||
1899 | { | ||
1900 | foreach (IScriptInstance si in m_Scripts.Values) | ||
1901 | { | ||
1902 | if (!topScripts.ContainsKey(si.LocalID)) | ||
1903 | topScripts[si.RootLocalID] = 0; | ||
1904 | |||
1905 | // long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; | ||
1906 | // float framesElapsed = ticksElapsed / (18.1818 * TimeSpan.TicksPerMillisecond); | ||
1907 | |||
1908 | // Execution time of the script adjusted by it's measurement period to make scripts started at | ||
1909 | // different times comparable. | ||
1910 | // float adjustedExecutionTime | ||
1911 | // = (float)si.MeasurementPeriodExecutionTime | ||
1912 | // / ((float)(tickNow - si.MeasurementPeriodTickStart) / ScriptInstance.MaxMeasurementPeriod) | ||
1913 | // / TimeSpan.TicksPerMillisecond; | ||
1914 | |||
1915 | long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; | ||
1916 | |||
1917 | // Avoid divide by zerp | ||
1918 | if (ticksElapsed == 0) | ||
1919 | ticksElapsed = 1; | ||
1920 | |||
1921 | // Scale execution time to the ideal 55 fps frame time for these reasons. | ||
1922 | // | ||
1923 | // 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no | ||
1924 | // 'script execution time per frame', which is the original purpose of this value. | ||
1925 | // | ||
1926 | // 2) Giving the raw execution times is misleading since scripts start at different times, making | ||
1927 | // it impossible to compare scripts. | ||
1928 | // | ||
1929 | // 3) Scaling the raw execution time to the time that the script has been running is better but | ||
1930 | // is still misleading since a script that has just been rezzed may appear to have been running | ||
1931 | // for much longer. | ||
1932 | // | ||
1933 | // 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect | ||
1934 | // since the figure does not represent actual execution time and very hard running scripts will | ||
1935 | // never exceed 18ms (though this is a very high number for script execution so is a warning sign). | ||
1936 | float adjustedExecutionTime | ||
1937 | = ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f; | ||
1938 | |||
1939 | topScripts[si.RootLocalID] += adjustedExecutionTime; | ||
1940 | } | ||
1941 | } | ||
1942 | |||
1943 | return topScripts; | ||
1944 | } | ||
1945 | |||
1894 | public void SuspendScript(UUID itemID) | 1946 | public void SuspendScript(UUID itemID) |
1895 | { | 1947 | { |
1896 | // m_log.DebugFormat("[XEngine]: Received request to suspend script with ID {0}", itemID); | 1948 | // m_log.DebugFormat("[XEngine]: Received request to suspend script with ID {0}", itemID); |