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