aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
authorOren Hurvitz2015-07-27 09:03:14 +0300
committerOren Hurvitz2015-08-11 07:35:41 +0100
commit287096d826060d96454d2b186e082a95f1e5724a (patch)
tree79b1a97e593945b023745f70e055fbdfa5884f71 /OpenSim/Region/ScriptEngine/Shared
parentFixed mistakes related to confusion between Environment.TickCount (millisecon... (diff)
downloadopensim-SC_OLD-287096d826060d96454d2b186e082a95f1e5724a.zip
opensim-SC_OLD-287096d826060d96454d2b186e082a95f1e5724a.tar.gz
opensim-SC_OLD-287096d826060d96454d2b186e082a95f1e5724a.tar.bz2
opensim-SC_OLD-287096d826060d96454d2b186e082a95f1e5724a.tar.xz
Improved calculation of Script Execution TimeStarted
1. Use a Stopwatch (a high-resolution timer) 2. Whenever we start a new measurement period, zero out the total execution time (previously it just kept accumulating) 3. Changed the measurement period from 30 minutes to 30 seconds. This is much more useful in the "Top Scripts" dialog, as it shows currently active scripts
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs18
1 files changed, 12 insertions, 6 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index bae66e8..05dea5d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -51,6 +51,7 @@ using OpenSim.Region.ScriptEngine.Shared.Api.Runtime;
51using OpenSim.Region.ScriptEngine.Shared.ScriptBase; 51using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
52using OpenSim.Region.ScriptEngine.Shared.CodeTools; 52using OpenSim.Region.ScriptEngine.Shared.CodeTools;
53using OpenSim.Region.ScriptEngine.Interfaces; 53using OpenSim.Region.ScriptEngine.Interfaces;
54using System.Diagnostics;
54 55
55namespace OpenSim.Region.ScriptEngine.Shared.Instance 56namespace OpenSim.Region.ScriptEngine.Shared.Instance
56{ 57{
@@ -202,7 +203,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
202 203
203 public long MeasurementPeriodExecutionTime { get; private set; } 204 public long MeasurementPeriodExecutionTime { get; private set; }
204 205
205 public static readonly long MaxMeasurementPeriod = 30 * (TimeSpan.TicksPerMinute / TimeSpan.TicksPerMillisecond); 206 public static readonly int MaxMeasurementPeriod = 30 * 1000; // show the *recent* time used by the script, to find currently active scripts
206 207
207 private bool m_coopTermination; 208 private bool m_coopTermination;
208 209
@@ -831,15 +832,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
831 m_EventStart = DateTime.Now; 832 m_EventStart = DateTime.Now;
832 m_InEvent = true; 833 m_InEvent = true;
833 834
834 int start = Util.EnvironmentTickCount();
835
836 // Reset the measurement period when we reach the end of the current one. 835 // Reset the measurement period when we reach the end of the current one.
837 if (start - MeasurementPeriodTickStart > MaxMeasurementPeriod) 836 if (Util.EnvironmentTickCountSubtract((int)MeasurementPeriodTickStart) > MaxMeasurementPeriod)
838 MeasurementPeriodTickStart = start; 837 {
838 MeasurementPeriodTickStart = Util.EnvironmentTickCount();
839 MeasurementPeriodExecutionTime = 0;
840 }
839 841
842 Stopwatch executionTime = new Stopwatch();
843 executionTime.Start();
844
840 m_Script.ExecuteEvent(State, data.EventName, data.Params); 845 m_Script.ExecuteEvent(State, data.EventName, data.Params);
841 846
842 MeasurementPeriodExecutionTime += Util.EnvironmentTickCount() - start; 847 executionTime.Stop();
848 MeasurementPeriodExecutionTime += executionTime.ElapsedMilliseconds;
843 849
844 m_InEvent = false; 850 m_InEvent = false;
845 m_CurrentEvent = String.Empty; 851 m_CurrentEvent = String.Empty;