From 6d47ec571ad938ba97cc18515fcc5c1e89808aaf Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 23 Jul 2021 03:04:59 +0100 Subject: [PATCH] add another stat --- OpenSim/Framework/SimStats.cs | 24 +++------ .../Framework/Scenes/SimStatsReporter.cs | 53 ++++--------------- .../Shared/Api/Runtime/LSL_Constants.cs | 3 +- 3 files changed, 19 insertions(+), 61 deletions(-) diff --git a/OpenSim/Framework/SimStats.cs b/OpenSim/Framework/SimStats.cs index adda209b50..7557fdaeb5 100644 --- a/OpenSim/Framework/SimStats.cs +++ b/OpenSim/Framework/SimStats.cs @@ -91,8 +91,9 @@ namespace OpenSim.Framework TotalGeoPrim = 1003, TotalMesh = 1004, ScriptEngineThreadCount = 1005, + NPCs = 1006, - SimExtraCountEnd = 1006 + SimExtraCountEnd = 1007 } // stats values are stored on a float[] @@ -155,23 +156,9 @@ namespace OpenSim.Framework TotalGeoPrim = 44, TotalMesh = 45, ScriptEngineThreadCount = 46, + NPCs = 47, - ArraySize = 47 // last is marker for array size - } - - public enum ExtraStatsIndex : int - { - // extra stats IDs irrelevant, just far from viewer defined ones - SimExtraCountStart = 1000, - - internalLSLScriptLinesPerSecond = 1000, - FrameDilation2 = 1001, - UsersLoggingIn = 1002, - TotalGeoPrim = 1003, - TotalMesh = 1004, - ThreadCount = 1005, - - SimExtraCountEnd = 1006 + ArraySize = 48 // last is marker for array size } /// @@ -250,7 +237,8 @@ namespace OpenSim.Framework (uint)StatsID.UsersLoggingIn, (uint)StatsID.TotalGeoPrim, (uint)StatsID.TotalMesh, - (uint)StatsID.ScriptEngineThreadCount + (uint)StatsID.ScriptEngineThreadCount, + (uint)StatsID.NPCs }; public SimStats( diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 5e2a2b7637..6ada566f3b 100755 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -147,14 +147,8 @@ namespace OpenSim.Region.Framework.Scenes private float m_sleeptimeMS; private float m_scriptTimeMS; - private int m_rootAgents; - private int m_childAgents; - private int m_numPrim; - private int m_numGeoPrim; - private int m_numMesh; private int m_inPacketsPerSecond; private int m_outPacketsPerSecond; - private int m_activePrim; private int m_unAckedBytes; private int m_pendingDownloads; private int m_pendingUploads = 0; // FIXME: Not currently filled in @@ -369,28 +363,19 @@ namespace OpenSim.Region.Framework.Scenes sparetime = totalFrameTime; #endregion - - m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); - m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); - m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount(); - m_numGeoPrim = m_scene.SceneGraph.GetTotalPrimObjectsCount(); - m_numMesh = m_scene.SceneGraph.GetTotalMeshObjectsCount(); - m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount(); - m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount(); - m_scriptLinesPerSecond = m_scene.SceneGraph.GetScriptLPS(); - - // FIXME: Checking for stat sanity is a complex approach. What we really need to do is fix the code - // so that stat numbers are always consistent. - CheckStatSanity(); + SceneGraph SG = m_scene.SceneGraph; + m_activeScripts = SG.GetActiveScriptsCount(); + m_scriptLinesPerSecond = SG.GetScriptLPS(); + float scriptTimeMS = m_scene.GetAndResetScriptExecutionTime() * perframefactor; newvalues[(int)StatsIndex.TimeDilation] = (Single.IsNaN(timeDilation)) ? 0.0f : (float)Math.Round(timeDilation, 3); newvalues[(int)StatsIndex.SimFPS] = (float)Math.Round(reportedFPS, 1); newvalues[(int)StatsIndex.PhysicsFPS] = (float)Math.Round(physfps, 1); newvalues[(int)StatsIndex.AgentUpdates] = m_agentUpdates * updateTimeFactor; - newvalues[(int)StatsIndex.Agents] = m_rootAgents; - newvalues[(int)StatsIndex.ChildAgents] = m_childAgents; - newvalues[(int)StatsIndex.TotalPrim] = m_numPrim; - newvalues[(int)StatsIndex.ActivePrim] = m_activePrim; + newvalues[(int)StatsIndex.Agents] = SG.GetRootAgentCount(); + newvalues[(int)StatsIndex.ChildAgents] = SG.GetChildAgentCount(); + newvalues[(int)StatsIndex.TotalPrim] = SG.GetTotalPrimObjectsCount(); + newvalues[(int)StatsIndex.ActivePrim] = SG.GetActiveObjectsCount(); newvalues[(int)StatsIndex.FrameMS] = totalFrameTime; newvalues[(int)StatsIndex.NetMS] = (float)Math.Round(m_netMS * perframefactor, 3); newvalues[(int)StatsIndex.PhysicsMS] = (float)Math.Round(physicsMS, 3); @@ -413,9 +398,10 @@ namespace OpenSim.Region.Framework.Scenes newvalues[(int)StatsIndex.LSLScriptLinesPerSecond] = (float)Math.Round(m_scriptLinesPerSecond * updateTimeFactor, 3); newvalues[(int)StatsIndex.FrameDilation2] = (Single.IsNaN(timeDilation)) ? 0.1f : (float)Math.Round(timeDilation, 1); newvalues[(int)StatsIndex.UsersLoggingIn] = m_usersLoggingIn; - newvalues[(int)StatsIndex.TotalGeoPrim] = m_numGeoPrim; - newvalues[(int)StatsIndex.TotalMesh] = m_numMesh; + newvalues[(int)StatsIndex.TotalGeoPrim] = SG.GetTotalPrimObjectsCount(); + newvalues[(int)StatsIndex.TotalMesh] = SG.GetTotalMeshObjectsCount(); newvalues[(int)StatsIndex.ScriptEngineThreadCount] = m_inUseThreads; + newvalues[(int)StatsIndex.NPCs] = SG.GetRootNPCCount(); lastReportedSimStats = newvalues; @@ -471,23 +457,6 @@ namespace OpenSim.Region.Framework.Scenes m_imageMS = 0; } - - internal void CheckStatSanity() - { - if (m_rootAgents < 0 || m_childAgents < 0) - { - handlerStatsIncorrect = OnStatsIncorrect; - if (handlerStatsIncorrect != null) - { - handlerStatsIncorrect(); - } - } - if (m_rootAgents == 0 && m_childAgents == 0) - { - m_unAckedBytes = 0; - } - } - # region methods called from Scene public void AddFrameStats(float _timeDilation, float _physicsFPS, float _agentMS, diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 83fdfc99fa..34de109656 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -806,7 +806,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const string TEXTURE_TRANSPARENT = "8dcd4a48-2d37-4909-9f78-f7a9eb4ef903"; public const string TEXTURE_MEDIA = "8b5fec65-8d8d-9dc5-cda8-8fdf2716e361"; - // Constants for osGetRegionStats + // Constants for osGetRegionStats this must match StatsIndex in SimStats.cs public const int STATS_TIME_DILATION = 0; public const int STATS_SIM_FPS = 1; public const int STATS_PHYSICS_FPS = 2; @@ -832,6 +832,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int STATS_SCRIPT_EPS = 28; public const int STATS_SCRIPT_TIME = 37; public const int STATS_SCRIPT_LPS = 38; + public const int STATS_SCRIPT_NPCS = 47; // Constants for osNpc* functions public const int OS_NPC_FLY = 0;