diff options
author | Justin Clark-Casey (justincc) | 2012-03-16 00:34:30 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-03-16 00:34:30 +0000 |
commit | a4b01ef38a735ffe70b402061871a9c99f2757ed (patch) | |
tree | b60dcc1cbfaeb0cb0184f4b9619a7e95afe0a4de /OpenSim/Region/ScriptEngine/Shared | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-a4b01ef38a735ffe70b402061871a9c99f2757ed.zip opensim-SC_OLD-a4b01ef38a735ffe70b402061871a9c99f2757ed.tar.gz opensim-SC_OLD-a4b01ef38a735ffe70b402061871a9c99f2757ed.tar.bz2 opensim-SC_OLD-a4b01ef38a735ffe70b402061871a9c99f2757ed.tar.xz |
Replace script-lines-per-second with the script execution time scaled by its measurement period and an idealised frame time.
The previous lines-per-second measurement used for top scripts report was inaccurate, since lines executed does not reflect time taken to execute.
Also, every fetch of the report would reset all the numbers limiting its usefulness and we weren't even guaranteed to see the top 100.
The actual measurement value should be script execution time per frame but XEngine does not work this way.
Therefore, we use actual script execution time scaled by the measurement period and an idealised frame time.
This is still not ideal but gives reasonable results and allows scripts to be compared.
This commit moves script execution time calculations from SceneGraph into IScriptModule implementations.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 968351b..b177287 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -172,6 +172,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
172 | 172 | ||
173 | public TaskInventoryItem ScriptTask { get; private set; } | 173 | public TaskInventoryItem ScriptTask { get; private set; } |
174 | 174 | ||
175 | public DateTime TimeStarted { get; private set; } | ||
176 | |||
177 | public long MeasurementPeriodTickStart { get; private set; } | ||
178 | |||
179 | public long MeasurementPeriodExecutionTime { get; private set; } | ||
180 | |||
181 | public static readonly long MaxMeasurementPeriod = 30 * TimeSpan.TicksPerMinute; | ||
182 | |||
175 | public void ClearQueue() | 183 | public void ClearQueue() |
176 | { | 184 | { |
177 | m_TimerQueued = false; | 185 | m_TimerQueued = false; |
@@ -458,6 +466,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
458 | 466 | ||
459 | Running = true; | 467 | Running = true; |
460 | 468 | ||
469 | TimeStarted = DateTime.Now; | ||
470 | MeasurementPeriodTickStart = Util.EnvironmentTickCount(); | ||
471 | MeasurementPeriodExecutionTime = 0; | ||
472 | |||
461 | if (EventQueue.Count > 0) | 473 | if (EventQueue.Count > 0) |
462 | { | 474 | { |
463 | if (m_CurrentWorkItem == null) | 475 | if (m_CurrentWorkItem == null) |
@@ -710,8 +722,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
710 | m_EventStart = DateTime.Now; | 722 | m_EventStart = DateTime.Now; |
711 | m_InEvent = true; | 723 | m_InEvent = true; |
712 | 724 | ||
725 | int start = Util.EnvironmentTickCount(); | ||
726 | |||
727 | // Reset the measurement period when we reach the end of the current one. | ||
728 | if (start - MeasurementPeriodTickStart > MaxMeasurementPeriod) | ||
729 | MeasurementPeriodTickStart = start; | ||
730 | |||
713 | m_Script.ExecuteEvent(State, data.EventName, data.Params); | 731 | m_Script.ExecuteEvent(State, data.EventName, data.Params); |
714 | 732 | ||
733 | MeasurementPeriodExecutionTime += Util.EnvironmentTickCount() - start; | ||
734 | |||
715 | m_InEvent = false; | 735 | m_InEvent = false; |
716 | m_CurrentEvent = String.Empty; | 736 | m_CurrentEvent = String.Empty; |
717 | 737 | ||
@@ -720,7 +740,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
720 | // This will be the very first event we deliver | 740 | // This will be the very first event we deliver |
721 | // (state_entry) in default state | 741 | // (state_entry) in default state |
722 | // | 742 | // |
723 | |||
724 | SaveState(m_Assembly); | 743 | SaveState(m_Assembly); |
725 | 744 | ||
726 | m_SaveState = false; | 745 | m_SaveState = false; |