Make reported sim fps more accurate, in line with frame time ms
Also remove some unused fields and improve naming on others.remove-scene-viewer
parent
3142982353
commit
7d033187d8
|
@ -137,8 +137,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
protected IDialogModule m_dialogModule;
|
protected IDialogModule m_dialogModule;
|
||||||
protected IEntityTransferModule m_teleportModule;
|
protected IEntityTransferModule m_teleportModule;
|
||||||
protected ICapabilitiesModule m_capsModule;
|
protected ICapabilitiesModule m_capsModule;
|
||||||
// Central Update Loop
|
|
||||||
protected int m_fps = 10;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Current scene frame number
|
/// Current scene frame number
|
||||||
|
@ -149,8 +147,20 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
protected set;
|
protected set;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected float m_timespan = 0.089f;
|
/// <summary>
|
||||||
protected DateTime m_lastupdate = DateTime.UtcNow;
|
/// The minimum length of time in seconds that will be taken for a scene frame. If the frame takes less time then we
|
||||||
|
/// will sleep for the remaining period.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// One can tweak this number to experiment. One current effect of reducing it is to make avatar animations
|
||||||
|
/// occur too quickly (viewer 1) or with even more slide (viewer 2).
|
||||||
|
/// </remarks>
|
||||||
|
protected float m_minFrameTimespan = 0.089f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The time of the last frame update.
|
||||||
|
/// </summary>
|
||||||
|
protected DateTime m_lastFrameUpdate = DateTime.UtcNow;
|
||||||
|
|
||||||
// TODO: Possibly stop other classes being able to manipulate this directly.
|
// TODO: Possibly stop other classes being able to manipulate this directly.
|
||||||
private SceneGraph m_sceneGraph;
|
private SceneGraph m_sceneGraph;
|
||||||
|
@ -1211,7 +1221,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate;
|
TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastFrameUpdate;
|
||||||
float physicsFPS = 0f;
|
float physicsFPS = 0f;
|
||||||
|
|
||||||
int maintc = Util.EnvironmentTickCount();
|
int maintc = Util.EnvironmentTickCount();
|
||||||
|
@ -1263,7 +1273,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
if (Frame % m_update_physics == 0)
|
if (Frame % m_update_physics == 0)
|
||||||
{
|
{
|
||||||
if (m_physics_enabled)
|
if (m_physics_enabled)
|
||||||
physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan));
|
physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_minFrameTimespan));
|
||||||
if (SynchronizeScene != null)
|
if (SynchronizeScene != null)
|
||||||
SynchronizeScene(this);
|
SynchronizeScene(this);
|
||||||
}
|
}
|
||||||
|
@ -1379,11 +1389,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
m_lastupdate = DateTime.UtcNow;
|
m_lastFrameUpdate = DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
maintc = Util.EnvironmentTickCountSubtract(maintc);
|
maintc = Util.EnvironmentTickCountSubtract(maintc);
|
||||||
maintc = (int)(m_timespan * 1000) - maintc;
|
maintc = (int)(m_minFrameTimespan * 1000) - maintc;
|
||||||
|
|
||||||
if (maintc > 0)
|
if (maintc > 0)
|
||||||
Thread.Sleep(maintc);
|
Thread.Sleep(maintc);
|
||||||
|
|
|
@ -174,6 +174,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Perform a physics frame update.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="elapsed"></param>
|
||||||
|
/// <returns></returns>
|
||||||
protected internal float UpdatePhysics(double elapsed)
|
protected internal float UpdatePhysics(double elapsed)
|
||||||
{
|
{
|
||||||
lock (m_syncRoot)
|
lock (m_syncRoot)
|
||||||
|
|
|
@ -37,6 +37,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
public class SimStatsReporter
|
public class SimStatsReporter
|
||||||
{
|
{
|
||||||
|
// private static readonly log4net.ILog m_log
|
||||||
|
// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
public delegate void SendStatResult(SimStats stats);
|
public delegate void SendStatResult(SimStats stats);
|
||||||
|
|
||||||
public delegate void YourStatsAreWrong();
|
public delegate void YourStatsAreWrong();
|
||||||
|
@ -165,18 +168,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
#region various statistic googly moogly
|
#region various statistic googly moogly
|
||||||
|
|
||||||
// Our FPS is actually 10fps, so multiplying by 5 to get the amount that people expect there
|
|
||||||
// 0-50 is pretty close to 0-45
|
|
||||||
float simfps = (int) ((m_fps * 5));
|
|
||||||
// save the reported value so there is something available for llGetRegionFPS
|
// save the reported value so there is something available for llGetRegionFPS
|
||||||
lastReportedSimFPS = (float)simfps / statsUpdateFactor;
|
lastReportedSimFPS = (float)m_fps / statsUpdateFactor;
|
||||||
|
|
||||||
//if (simfps > 45)
|
|
||||||
//simfps = simfps - (simfps - 45);
|
|
||||||
//if (simfps < 0)
|
|
||||||
//simfps = 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
float physfps = ((m_pfps / 1000));
|
float physfps = ((m_pfps / 1000));
|
||||||
|
|
||||||
//if (physfps > 600)
|
//if (physfps > 600)
|
||||||
|
@ -197,7 +191,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
// 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change
|
// 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change
|
||||||
// values to X-per-second values.
|
// values to X-per-second values.
|
||||||
|
|
||||||
for (int i = 0; i<21;i++)
|
for (int i = 0; i < 21; i++)
|
||||||
{
|
{
|
||||||
sb[i] = new SimStatsPacket.StatBlock();
|
sb[i] = new SimStatsPacket.StatBlock();
|
||||||
}
|
}
|
||||||
|
@ -206,7 +200,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
|
sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
|
||||||
|
|
||||||
sb[1].StatID = (uint) Stats.SimFPS;
|
sb[1].StatID = (uint) Stats.SimFPS;
|
||||||
sb[1].StatValue = simfps/statsUpdateFactor;
|
sb[1].StatValue = m_fps/statsUpdateFactor;
|
||||||
|
|
||||||
sb[2].StatID = (uint) Stats.PhysicsFPS;
|
sb[2].StatID = (uint) Stats.PhysicsFPS;
|
||||||
sb[2].StatValue = physfps / statsUpdateFactor;
|
sb[2].StatValue = physfps / statsUpdateFactor;
|
||||||
|
@ -272,7 +266,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
SimStats simStats
|
SimStats simStats
|
||||||
= new SimStats(
|
= new SimStats(
|
||||||
ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity, rb, sb, m_scene.RegionInfo.originRegionID);
|
ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity,
|
||||||
|
rb, sb, m_scene.RegionInfo.originRegionID);
|
||||||
|
|
||||||
handlerSendStatResult = OnSendStatsResult;
|
handlerSendStatResult = OnSendStatsResult;
|
||||||
if (handlerSendStatResult != null)
|
if (handlerSendStatResult != null)
|
||||||
|
@ -395,30 +390,32 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
m_frameMS += ms;
|
m_frameMS += ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNetMS(int ms)
|
public void addNetMS(int ms)
|
||||||
{
|
{
|
||||||
m_netMS += ms;
|
m_netMS += ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAgentMS(int ms)
|
public void addAgentMS(int ms)
|
||||||
{
|
{
|
||||||
m_agentMS += ms;
|
m_agentMS += ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPhysicsMS(int ms)
|
public void addPhysicsMS(int ms)
|
||||||
{
|
{
|
||||||
m_physicsMS += ms;
|
m_physicsMS += ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addImageMS(int ms)
|
public void addImageMS(int ms)
|
||||||
{
|
{
|
||||||
m_imageMS += ms;
|
m_imageMS += ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addOtherMS(int ms)
|
public void addOtherMS(int ms)
|
||||||
{
|
{
|
||||||
m_otherMS += ms;
|
m_otherMS += ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private static readonly log4net.ILog m_log
|
|
||||||
// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
public void AddPendingDownloads(int count)
|
public void AddPendingDownloads(int count)
|
||||||
{
|
{
|
||||||
m_pendingDownloads += count;
|
m_pendingDownloads += count;
|
||||||
|
|
Loading…
Reference in New Issue