aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/XEngine
diff options
context:
space:
mode:
authorMelanie2012-03-18 20:44:56 +0000
committerMelanie2012-03-18 20:44:56 +0000
commitc7e302864a2eef7f9587ed22286c96a6074ac5b3 (patch)
tree8f0df2f66811309fd790966770434fa3ff68bfdf /OpenSim/Region/ScriptEngine/XEngine
parentMerge branch 'ubitwork' (diff)
parentAmend to previous commit: normalize strings ToLower. (diff)
downloadopensim-SC_OLD-c7e302864a2eef7f9587ed22286c96a6074ac5b3.zip
opensim-SC_OLD-c7e302864a2eef7f9587ed22286c96a6074ac5b3.tar.gz
opensim-SC_OLD-c7e302864a2eef7f9587ed22286c96a6074ac5b3.tar.bz2
opensim-SC_OLD-c7e302864a2eef7f9587ed22286c96a6074ac5b3.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs OpenSim/Region/Framework/Scenes/Scene.cs
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs61
1 files changed, 59 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index ee5f519..eb10975 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -448,6 +448,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
448 if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) 448 if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene))
449 return; 449 return;
450 450
451 MainConsole.Instance.OutputFormat(GetStatusReport());
452 }
453
454 public string GetStatusReport()
455 {
451 StringBuilder sb = new StringBuilder(); 456 StringBuilder sb = new StringBuilder();
452 sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName); 457 sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName);
453 458
@@ -475,7 +480,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
475 Listener l = AsyncCommandManager.GetListenerPlugin(this); 480 Listener l = AsyncCommandManager.GetListenerPlugin(this);
476 sb.AppendFormat("Listeners : {0}\n", l.ListenerCount); 481 sb.AppendFormat("Listeners : {0}\n", l.ListenerCount);
477 482
478 MainConsole.Instance.OutputFormat(sb.ToString()); 483 return sb.ToString();
479 } 484 }
480 485
481 public void HandleShowScripts(string module, string[] cmdparams) 486 public void HandleShowScripts(string module, string[] cmdparams)
@@ -1154,7 +1159,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1154 1159
1155 if (!m_PrimObjects[localID].Contains(itemID)) 1160 if (!m_PrimObjects[localID].Contains(itemID))
1156 m_PrimObjects[localID].Add(itemID); 1161 m_PrimObjects[localID].Add(itemID);
1157
1158 } 1162 }
1159 1163
1160 if (!m_Assemblies.ContainsKey(assetID)) 1164 if (!m_Assemblies.ContainsKey(assetID))
@@ -1981,6 +1985,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1981 } 1985 }
1982 } 1986 }
1983 1987
1988 public Dictionary<uint, float> GetObjectScriptsExecutionTimes()
1989 {
1990 long tickNow = Util.EnvironmentTickCount();
1991 Dictionary<uint, float> topScripts = new Dictionary<uint, float>();
1992
1993 lock (m_Scripts)
1994 {
1995 foreach (IScriptInstance si in m_Scripts.Values)
1996 {
1997 if (!topScripts.ContainsKey(si.LocalID))
1998 topScripts[si.RootLocalID] = 0;
1999
2000// long ticksElapsed = tickNow - si.MeasurementPeriodTickStart;
2001// float framesElapsed = ticksElapsed / (18.1818 * TimeSpan.TicksPerMillisecond);
2002
2003 // Execution time of the script adjusted by it's measurement period to make scripts started at
2004 // different times comparable.
2005// float adjustedExecutionTime
2006// = (float)si.MeasurementPeriodExecutionTime
2007// / ((float)(tickNow - si.MeasurementPeriodTickStart) / ScriptInstance.MaxMeasurementPeriod)
2008// / TimeSpan.TicksPerMillisecond;
2009
2010 long ticksElapsed = tickNow - si.MeasurementPeriodTickStart;
2011
2012 // Avoid divide by zerp
2013 if (ticksElapsed == 0)
2014 ticksElapsed = 1;
2015
2016 // Scale execution time to the ideal 55 fps frame time for these reasons.
2017 //
2018 // 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no
2019 // 'script execution time per frame', which is the original purpose of this value.
2020 //
2021 // 2) Giving the raw execution times is misleading since scripts start at different times, making
2022 // it impossible to compare scripts.
2023 //
2024 // 3) Scaling the raw execution time to the time that the script has been running is better but
2025 // is still misleading since a script that has just been rezzed may appear to have been running
2026 // for much longer.
2027 //
2028 // 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect
2029 // since the figure does not represent actual execution time and very hard running scripts will
2030 // never exceed 18ms (though this is a very high number for script execution so is a warning sign).
2031 float adjustedExecutionTime
2032 = ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f;
2033
2034 topScripts[si.RootLocalID] += adjustedExecutionTime;
2035 }
2036 }
2037
2038 return topScripts;
2039 }
2040
1984 public void SuspendScript(UUID itemID) 2041 public void SuspendScript(UUID itemID)
1985 { 2042 {
1986// m_log.DebugFormat("[XEngine]: Received request to suspend script with ID {0}", itemID); 2043// m_log.DebugFormat("[XEngine]: Received request to suspend script with ID {0}", itemID);