aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-12-05 23:27:50 +0000
committerJustin Clark-Casey (justincc)2012-12-05 23:27:50 +0000
commit652f4bcb425646aab2096da99aa00016dfe639fd (patch)
tree27e06ee84673c06cb4fb87ee59a2e80dfebfab5e /OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
parentAdd IScriptInstance.EventsProcessed stat so that we can record this informati... (diff)
downloadopensim-SC_OLD-652f4bcb425646aab2096da99aa00016dfe639fd.zip
opensim-SC_OLD-652f4bcb425646aab2096da99aa00016dfe639fd.tar.gz
opensim-SC_OLD-652f4bcb425646aab2096da99aa00016dfe639fd.tar.bz2
opensim-SC_OLD-652f4bcb425646aab2096da99aa00016dfe639fd.tar.xz
For now, sort "show scripts" output in descending order sorted by events processed.
For debug purposes - should later add options to allow different sorting or show only highest 10, etc.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine/XEngine.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs24
1 files changed, 21 insertions, 3 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 2136fe8..394826e 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -30,6 +30,7 @@ using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Globalization; 31using System.Globalization;
32using System.IO; 32using System.IO;
33using System.Linq;
33using System.Reflection; 34using System.Reflection;
34using System.Security; 35using System.Security;
35using System.Security.Policy; 36using System.Security.Policy;
@@ -377,9 +378,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine
377 /// </summary> 378 /// </summary>
378 /// <param name="cmdparams"></param> 379 /// <param name="cmdparams"></param>
379 /// <param name="instance"></param> 380 /// <param name="instance"></param>
380 /// <returns>true if we're okay to proceed, false if not.</returns> 381 /// <param name="comparer">Basis on which to sort output. Can be null if no sort needs to take place</param>
381 private void HandleScriptsAction(string[] cmdparams, Action<IScriptInstance> action) 382 private void HandleScriptsAction(string[] cmdparams, Action<IScriptInstance> action)
382 { 383 {
384 HandleScriptsAction<object>(cmdparams, action, null);
385 }
386
387 /// <summary>
388 /// Parse the raw item id into a script instance from the command params if it's present.
389 /// </summary>
390 /// <param name="cmdparams"></param>
391 /// <param name="instance"></param>
392 /// <param name="keySelector">Basis on which to sort output. Can be null if no sort needs to take place</param>
393 private void HandleScriptsAction<TKey>(
394 string[] cmdparams, Action<IScriptInstance> action, Func<IScriptInstance, TKey> keySelector)
395 {
383 if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) 396 if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene))
384 return; 397 return;
385 398
@@ -390,7 +403,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
390 403
391 if (cmdparams.Length == 2) 404 if (cmdparams.Length == 2)
392 { 405 {
393 foreach (IScriptInstance instance in m_Scripts.Values) 406 IEnumerable<IScriptInstance> scripts = m_Scripts.Values;
407
408 if (keySelector != null)
409 scripts = scripts.OrderBy<IScriptInstance, TKey>(keySelector);
410
411 foreach (IScriptInstance instance in scripts)
394 action(instance); 412 action(instance);
395 413
396 return; 414 return;
@@ -478,7 +496,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
478 } 496 }
479 } 497 }
480 498
481 HandleScriptsAction(cmdparams, HandleShowScript); 499 HandleScriptsAction<long>(cmdparams, HandleShowScript, si => si.EventsProcessed);
482 } 500 }
483 501
484 private void HandleShowScript(IScriptInstance instance) 502 private void HandleShowScript(IScriptInstance instance)