aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes
diff options
context:
space:
mode:
authorTeravus Ovares2008-05-25 20:50:45 +0000
committerTeravus Ovares2008-05-25 20:50:45 +0000
commitc20f7d6171a9df151c3ccde063336338da9ae322 (patch)
treea6093b52da4093e3b692771a421ce4a55052d24b /OpenSim/Region/Environment/Scenes
parentThank you very much, Melanie for a patch that: (diff)
downloadopensim-SC-c20f7d6171a9df151c3ccde063336338da9ae322.zip
opensim-SC-c20f7d6171a9df151c3ccde063336338da9ae322.tar.gz
opensim-SC-c20f7d6171a9df151c3ccde063336338da9ae322.tar.bz2
opensim-SC-c20f7d6171a9df151c3ccde063336338da9ae322.tar.xz
* A hacky Top Scripts display. It isn't accurate as far as ms accounting, however you can use it to help find out what scripts are causing your simulator to cry.
* Access it from the Estate tools/Debug tab.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Scenes/EventManager.cs15
-rw-r--r--OpenSim/Region/Environment/Scenes/InnerScene.cs31
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs5
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs32
4 files changed, 83 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/EventManager.cs b/OpenSim/Region/Environment/Scenes/EventManager.cs
index a3f5d2f..1c345ba 100644
--- a/OpenSim/Region/Environment/Scenes/EventManager.cs
+++ b/OpenSim/Region/Environment/Scenes/EventManager.cs
@@ -174,6 +174,9 @@ namespace OpenSim.Region.Environment.Scenes
174 174
175 public event AvatarKillData OnAvatarKilled; 175 public event AvatarKillData OnAvatarKilled;
176 176
177 public delegate void ScriptTimerEvent(uint localID, double timerinterval);
178
179 public event ScriptTimerEvent OnScriptTimerEvent;
177 180
178 181
179 public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj); 182 public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj);
@@ -332,6 +335,7 @@ namespace OpenSim.Region.Environment.Scenes
332 private RequestParcelPrimCountUpdate handlerRequestParcelPrimCountUpdate = null; 335 private RequestParcelPrimCountUpdate handlerRequestParcelPrimCountUpdate = null;
333 private ParcelPrimCountTainted handlerParcelPrimCountTainted = null; 336 private ParcelPrimCountTainted handlerParcelPrimCountTainted = null;
334 private ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = null; 337 private ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = null;
338 private ScriptTimerEvent handlerScriptTimerEvent = null;
335 339
336 public void TriggerOnScriptChangedEvent(uint localID, uint change) 340 public void TriggerOnScriptChangedEvent(uint localID, uint change)
337 { 341 {
@@ -755,5 +759,16 @@ namespace OpenSim.Region.Environment.Scenes
755 759
756 } 760 }
757 } 761 }
762 // this lets us keep track of nasty script events like timer, etc.
763 public void TriggerTimerEvent(uint objLocalID, double Interval)
764 {
765 handlerScriptTimerEvent = OnScriptTimerEvent;
766 if (handlerScriptTimerEvent != null)
767 {
768 handlerScriptTimerEvent(objLocalID, Interval);
769
770 }
771
772 }
758 } 773 }
759} 774}
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index 84de71f..d6e905b 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -846,6 +846,37 @@ namespace OpenSim.Region.Environment.Scenes
846 return result; 846 return result;
847 } 847 }
848 848
849 public Dictionary<uint, float> GetTopScripts()
850 {
851 Dictionary<uint, float> topScripts = new Dictionary<uint, float>();
852
853 List<EntityBase> EntityList = GetEntities();
854 int limit = 0;
855 foreach (EntityBase ent in EntityList)
856 {
857 if (ent is SceneObjectGroup)
858 {
859 SceneObjectGroup grp = (SceneObjectGroup)ent;
860 if ((grp.RootPart.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Scripted) != 0)
861 {
862 if (grp.scriptScore >= 0.01)
863 {
864 topScripts.Add(grp.LocalId, grp.scriptScore);
865 limit++;
866 if (limit >= 100)
867 {
868 break;
869 }
870
871 }
872 grp.scriptScore = 0;
873 }
874 }
875 }
876
877 return topScripts;
878 }
879
849 #endregion 880 #endregion
850 881
851 #region Other Methods 882 #region Other Methods
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 25b3d16..cd4be99 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -90,6 +90,7 @@ namespace OpenSim.Region.Environment.Scenes
90 /// since the group's last persistent backup 90 /// since the group's last persistent backup
91 /// </summary> 91 /// </summary>
92 public bool HasGroupChanged = false; 92 public bool HasGroupChanged = false;
93 public float scriptScore = 0f;
93 94
94 95
95 96
@@ -959,6 +960,10 @@ namespace OpenSim.Region.Environment.Scenes
959 960
960 public void AddScriptLPS(int count) 961 public void AddScriptLPS(int count)
961 { 962 {
963 if (scriptScore + count >= float.MaxValue - count)
964 scriptScore = 0;
965
966 scriptScore += (float)count;
962 InnerScene d = m_scene.m_innerScene; 967 InnerScene d = m_scene.m_innerScene;
963 d.AddToScriptLPS(count); 968 d.AddToScriptLPS(count);
964 } 969 }
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index b724bda..c6b3059 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -2752,6 +2752,14 @@ namespace OpenSim.Region.Environment.Scenes
2752 PhysActor.OnCollisionUpdate -= PhysicsCollision; 2752 PhysActor.OnCollisionUpdate -= PhysicsCollision;
2753 } 2753 }
2754 } 2754 }
2755 if ((GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Scripted) != 0)
2756 {
2757 m_parentGroup.Scene.EventManager.OnScriptTimerEvent += handleTimerAccounting;
2758 }
2759 else
2760 {
2761 m_parentGroup.Scene.EventManager.OnScriptTimerEvent -= handleTimerAccounting;
2762 }
2755 2763
2756 LocalFlags=(LLObject.ObjectFlags)objectflagupdate; 2764 LocalFlags=(LLObject.ObjectFlags)objectflagupdate;
2757 2765
@@ -2812,6 +2820,30 @@ namespace OpenSim.Region.Environment.Scenes
2812 GetProperties(client); 2820 GetProperties(client);
2813 m_updateFlag = 2; 2821 m_updateFlag = 2;
2814 } 2822 }
2823 private void handleTimerAccounting(uint localID, double interval)
2824 {
2825 if (localID == LocalId)
2826 {
2827
2828 float sec = (float)interval;
2829 if (m_parentGroup != null)
2830 {
2831 if (sec == 0)
2832 {
2833 if (m_parentGroup.scriptScore + 0.001f >= float.MaxValue - 0.001)
2834 m_parentGroup.scriptScore = 0;
2835
2836 m_parentGroup.scriptScore += 0.001f;
2837 return;
2838 }
2839
2840 if (m_parentGroup.scriptScore + (0.001f / sec) >= float.MaxValue - (0.001f / sec))
2841 m_parentGroup.scriptScore = 0;
2842 m_parentGroup.scriptScore += (0.001f / sec);
2843 }
2844
2845 }
2846 }
2815 2847
2816 } 2848 }
2817} 2849}