diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 32a98b435d..a9a4cda71c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1391,10 +1391,11 @@ namespace OpenSim.Region.Framework.Scenes int previousFrameTick; int maintc; int sleepMS; + int framestart; while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) { - maintc = Util.EnvironmentTickCount(); + framestart = Util.EnvironmentTickCount(); ++Frame; // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); @@ -1481,7 +1482,7 @@ namespace OpenSim.Region.Framework.Scenes // landMS = Util.EnvironmentTickCountSubtract(ldMS); //} - frameMS = Util.EnvironmentTickCountSubtract(maintc); + // frameMS = Util.EnvironmentTickCountSubtract(maintc); otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; // if (Frame%m_update_avatars == 0) @@ -1496,7 +1497,7 @@ namespace OpenSim.Region.Framework.Scenes // frameMS currently records work frame times, not total frame times (work + any required sleep to // reach min frame time. - StatsReporter.addFrameMS(frameMS); + // StatsReporter.addFrameMS(frameMS); StatsReporter.addAgentMS(agentMS); StatsReporter.addPhysicsMS(physicsMS + physicsMS2); @@ -1553,17 +1554,21 @@ namespace OpenSim.Region.Framework.Scenes previousFrameTick = m_lastFrameTick; m_lastFrameTick = Util.EnvironmentTickCount(); - maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); + maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); maintc = (int)(MinFrameTime * 1000) - maintc; m_firstHeartbeat = false; + sleepMS = Util.EnvironmentTickCount(); + if (maintc > 0) Thread.Sleep(maintc); sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); + frameMS = Util.EnvironmentTickCountSubtract(framestart); StatsReporter.addSleepMS(sleepMS); + StatsReporter.addFrameMS(frameMS); // Optionally warn if a frame takes double the amount of time that it should. if (DebugUpdates diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index e9589b86b8..94f1b151b7 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -253,24 +253,13 @@ namespace OpenSim.Region.Framework.Scenes physfps = 0; #endregion - - //Our time dilation is 0.91 when we're running a full speed, - // therefore to make sure we get an appropriate range, - // we have to factor in our error. (0.10f * statsUpdateFactor) - // multiplies the fix for the error times the amount of times it'll occur a second - // / 10 divides the value by the number of times the sim heartbeat runs (10fps) - // Then we divide the whole amount by the amount of seconds pass in between stats updates. - - // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change - // values to X-per-second values. - float factor = 1 / statsUpdateFactor; if (reportedFPS <= 0) reportedFPS = 1; float perframe = 1.0f / (float)reportedFPS; - float TotalFrameTime = 1000.0f * statsUpdateFactor * perframe; + float TotalFrameTime = m_frameMS * perframe; float targetframetime = 1100.0f / (float)m_nominalReportedFps; @@ -279,7 +268,8 @@ namespace OpenSim.Region.Framework.Scenes sparetime = 0; else { - sparetime = TotalFrameTime - m_frameMS * perframe; + sparetime = m_frameMS - m_physicsMS - m_agentMS; + sparetime *= perframe; if (sparetime < 0) sparetime = 0; else if (sparetime > TotalFrameTime) @@ -290,7 +280,7 @@ namespace OpenSim.Region.Framework.Scenes // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; // m_imageMS m_netMS are not included in m_frameMS - m_otherMS = m_frameMS - m_physicsMS - m_agentMS; + m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS; if (m_otherMS < 0) m_otherMS = 0;