From 9cd9e90e7f174ab0d84af2df6aff7d23b3493552 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 6 Feb 2008 08:03:22 +0000 Subject: * Added Active Scripts to report the number of scripts running to Sim Stats * Added Script Performance to report the number of functions run per second to Sim Stats. * Removed a few warnings (@.@ up to 50 now) --- OpenSim/Region/Environment/Scenes/InnerScene.cs | 28 ++++++++++++++++--- OpenSim/Region/Environment/Scenes/Scene.cs | 2 ++ .../Scenes/SceneObjectGroup.Inventory.cs | 11 ++++++++ .../Region/Environment/Scenes/SceneObjectGroup.cs | 12 +++++++++ .../Scenes/SceneObjectPart.Inventory.cs | 22 +++++++++++++++ .../Region/Environment/Scenes/SimStatsReporter.cs | 31 ++++++++++++++++++++-- 6 files changed, 100 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 49aeaf9..8a7402c 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -67,6 +67,9 @@ namespace OpenSim.Region.Environment.Scenes protected int m_numChildAgents = 0; protected int m_physicalPrim = 0; + protected int m_activeScripts = 0; + protected int m_scriptLPS = 0; + internal object m_syncRoot = new object(); public PhysicsScene _PhyScene; @@ -201,6 +204,16 @@ namespace OpenSim.Region.Environment.Scenes m_physicalPrim--; } + public void AddToScriptLPS(int number) + { + m_scriptLPS += number; + } + + public void AddActiveScripts(int number) + { + m_activeScripts += number; + } + public void RemovePrim(uint localID, LLUUID avatar_deleter) { List EntityList = GetEntities(); @@ -322,6 +335,17 @@ namespace OpenSim.Region.Environment.Scenes return m_physicalPrim; } + public int GetActiveScripts() + { + return m_activeScripts; + } + + public int GetScriptLPS() + { + int returnval = m_scriptLPS; + m_scriptLPS = 0; + return returnval; + } #endregion #region Get Methods @@ -546,10 +570,6 @@ namespace OpenSim.Region.Environment.Scenes //m_log.Info("[DISTANCE]: " + distResult.ToString()); - if (distResult > 60) - { - int x = 0; - } if (distResult < presence.DrawDistance) { // Send Only if we don't already know about it. diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index a724ac0..d0acded 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -639,6 +639,8 @@ namespace OpenSim.Region.Environment.Scenes m_statsReporter.addFrameMS(frameMS); m_statsReporter.addPhysicsMS(physicsMS); m_statsReporter.addOtherMS(otherMS); + m_statsReporter.SetActiveScripts(m_innerScene.GetActiveScripts()); + m_statsReporter.addScriptLines(m_innerScene.GetScriptLPS()); } catch (NotImplementedException) diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs index 0956f74..1e99079 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs @@ -93,6 +93,17 @@ namespace OpenSim.Region.Environment.Scenes part.StartScripts(); } } + + public void StopScripts() + { + lock (m_parts) + { + foreach (SceneObjectPart part in m_parts.Values) + { + part.StopScripts(); + } + } + } /// Start a given script. /// diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 4fe7b55..eb5a80c 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -1702,6 +1702,18 @@ namespace OpenSim.Region.Environment.Scenes m_parts.Clear(); } + public void AddScriptLPS(int count) + { + InnerScene d = m_scene.m_innerScene; + d.AddToScriptLPS(count); + } + + public void AddActiveScriptCount(int count) + { + InnerScene d = m_scene.m_innerScene; + d.AddActiveScripts(count); + } + public override void SetText(string text, Vector3 color, double alpha) { Color = Color.FromArgb(0xff - (int) (alpha*0xff), diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs index d9ee94c..e8ffe0e 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs @@ -125,6 +125,20 @@ namespace OpenSim.Region.Environment.Scenes } } } + + public void StopScripts() + { + lock (m_taskInventory) + { + foreach (TaskInventoryItem item in m_taskInventory.Values) + { + if (10 == item.Type) + { + StopScript(item.ItemID); + } + } + } + } /// /// Start a script which is in this prim's inventory. @@ -144,6 +158,7 @@ namespace OpenSim.Region.Environment.Scenes { string script = Helpers.FieldToUTF8String(rezAsset.Data); m_parentGroup.Scene.EventManager.TriggerRezScript(LocalID, item.ItemID, script); + } else { @@ -167,6 +182,7 @@ namespace OpenSim.Region.Environment.Scenes if (m_taskInventory.ContainsKey(itemId)) { StartScript(m_taskInventory[itemId]); + m_parentGroup.AddActiveScriptCount(1); } else { @@ -187,6 +203,7 @@ namespace OpenSim.Region.Environment.Scenes if (m_taskInventory.ContainsKey(itemId)) { m_parentGroup.Scene.EventManager.TriggerRemoveScript(LocalID, itemId); + m_parentGroup.AddActiveScriptCount(-1); } else { @@ -295,6 +312,11 @@ namespace OpenSim.Region.Environment.Scenes return false; } + public void AddScriptLPS(int count) + { + m_parentGroup.AddScriptLPS(count); + } + /// /// Remove an item from this prim's inventory /// diff --git a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs index 3bd7e4a..f2cefb5 100644 --- a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs @@ -51,10 +51,13 @@ namespace OpenSim.Region.Environment.Scenes PhysicsMS = 7, AgentMS = 8, ImageMS = 9, + ScriptMS = 10, TotalPrim = 11, ActivePrim = 12, Agents = 13, ChildAgents = 14, + ActiveScripts = 15, + ScriptLinesPerSecond = 16, InPacketsPerSecond = 17, OutPacketsPerSecond = 18, PendingDownloads = 19, @@ -74,12 +77,15 @@ namespace OpenSim.Region.Environment.Scenes private int m_fps = 0; private float m_pfps = 0; private int m_agentUpdates = 0; + private int m_frameMS = 0; private int m_netMS = 0; private int m_agentMS = 0; private int m_physicsMS = 0; private int m_imageMS = 0; private int m_otherMS = 0; + private int m_scriptMS = 0; + private int m_rootAgents = 0; private int m_childAgents = 0; private int m_numPrim = 0; @@ -89,9 +95,11 @@ namespace OpenSim.Region.Environment.Scenes private int m_unAckedBytes = 0; private int m_pendingDownloads = 0; private int m_pendingUploads = 0; + private int m_activeScripts = 0; + private int m_scriptLinesPerSecond = 0; - SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[19]; + SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21]; SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); SimStatsPacket statpack = (SimStatsPacket)PacketPool.Instance.GetPacket(PacketType.SimStats); @@ -106,7 +114,7 @@ namespace OpenSim.Region.Environment.Scenes statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); ReportingRegion = regionData; - for (int i = 0; i<19;i++) + for (int i = 0; i<21;i++) { sb[i] = new SimStatsPacket.StatBlock(); } @@ -222,6 +230,12 @@ namespace OpenSim.Region.Environment.Scenes sb[18].StatID = (uint)Stats.PendingUploads; sb[18].StatValue = m_pendingUploads; + sb[19].StatID = (uint)Stats.ActiveScripts; + sb[19].StatValue = m_activeScripts; + + sb[20].StatID = (uint)Stats.ScriptLinesPerSecond; + sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor; + statpack.Stat = sb; if (OnSendStatsResult != null) @@ -241,12 +255,15 @@ namespace OpenSim.Region.Environment.Scenes m_inPacketsPerSecond = 0; m_outPacketsPerSecond = 0; m_unAckedBytes = 0; + m_scriptLinesPerSecond = 0; + m_frameMS = 0; m_agentMS = 0; m_netMS = 0; m_physicsMS = 0; m_imageMS = 0; m_otherMS = 0; + m_scriptMS = 0; } # region methods called from Scene @@ -344,6 +361,16 @@ namespace OpenSim.Region.Environment.Scenes m_pendingDownloads += count; } + public void addScriptLines(int count) + { + m_scriptLinesPerSecond += count; + } + + public void SetActiveScripts(int count) + { + m_activeScripts = count; + } + #endregion } -- cgit v1.1