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
This commit is contained in:
Melanie
2012-03-18 20:44:56 +00:00
48 changed files with 1088 additions and 399 deletions

View File

@@ -448,6 +448,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene))
return;
MainConsole.Instance.OutputFormat(GetStatusReport());
}
public string GetStatusReport()
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName);
@@ -475,7 +480,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
Listener l = AsyncCommandManager.GetListenerPlugin(this);
sb.AppendFormat("Listeners : {0}\n", l.ListenerCount);
MainConsole.Instance.OutputFormat(sb.ToString());
return sb.ToString();
}
public void HandleShowScripts(string module, string[] cmdparams)
@@ -1154,7 +1159,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (!m_PrimObjects[localID].Contains(itemID))
m_PrimObjects[localID].Add(itemID);
}
if (!m_Assemblies.ContainsKey(assetID))
@@ -1981,6 +1985,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
}
public Dictionary<uint, float> GetObjectScriptsExecutionTimes()
{
long tickNow = Util.EnvironmentTickCount();
Dictionary<uint, float> topScripts = new Dictionary<uint, float>();
lock (m_Scripts)
{
foreach (IScriptInstance si in m_Scripts.Values)
{
if (!topScripts.ContainsKey(si.LocalID))
topScripts[si.RootLocalID] = 0;
// long ticksElapsed = tickNow - si.MeasurementPeriodTickStart;
// float framesElapsed = ticksElapsed / (18.1818 * TimeSpan.TicksPerMillisecond);
// Execution time of the script adjusted by it's measurement period to make scripts started at
// different times comparable.
// float adjustedExecutionTime
// = (float)si.MeasurementPeriodExecutionTime
// / ((float)(tickNow - si.MeasurementPeriodTickStart) / ScriptInstance.MaxMeasurementPeriod)
// / TimeSpan.TicksPerMillisecond;
long ticksElapsed = tickNow - si.MeasurementPeriodTickStart;
// Avoid divide by zerp
if (ticksElapsed == 0)
ticksElapsed = 1;
// Scale execution time to the ideal 55 fps frame time for these reasons.
//
// 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no
// 'script execution time per frame', which is the original purpose of this value.
//
// 2) Giving the raw execution times is misleading since scripts start at different times, making
// it impossible to compare scripts.
//
// 3) Scaling the raw execution time to the time that the script has been running is better but
// is still misleading since a script that has just been rezzed may appear to have been running
// for much longer.
//
// 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect
// since the figure does not represent actual execution time and very hard running scripts will
// never exceed 18ms (though this is a very high number for script execution so is a warning sign).
float adjustedExecutionTime
= ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f;
topScripts[si.RootLocalID] += adjustedExecutionTime;
}
}
return topScripts;
}
public void SuspendScript(UUID itemID)
{
// m_log.DebugFormat("[XEngine]: Received request to suspend script with ID {0}", itemID);