aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SimStatsReporter.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SimStatsReporter.cs93
1 files changed, 59 insertions, 34 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index 96317c3..20919a1 100644
--- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
@@ -164,7 +164,7 @@ namespace OpenSim.Region.Framework.Scenes
164 164
165 // saved last reported value so there is something available for llGetRegionFPS 165 // saved last reported value so there is something available for llGetRegionFPS
166 private float lastReportedSimFPS; 166 private float lastReportedSimFPS;
167 private float[] lastReportedSimStats = new float[22]; 167 private float[] lastReportedSimStats = new float[23];
168 private float m_pfps; 168 private float m_pfps;
169 169
170 /// <summary> 170 /// <summary>
@@ -178,12 +178,13 @@ namespace OpenSim.Region.Framework.Scenes
178 private int m_objectUpdates; 178 private int m_objectUpdates;
179 179
180 private int m_frameMS; 180 private int m_frameMS;
181 private int m_spareMS; 181
182 private int m_netMS; 182 private int m_netMS;
183 private int m_agentMS; 183 private int m_agentMS;
184 private int m_physicsMS; 184 private int m_physicsMS;
185 private int m_imageMS; 185 private int m_imageMS;
186 private int m_otherMS; 186 private int m_otherMS;
187 private int m_sleeptimeMS;
187 188
188//Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. 189//Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed.
189//Ckrinke private int m_scriptMS = 0; 190//Ckrinke private int m_scriptMS = 0;
@@ -260,7 +261,7 @@ namespace OpenSim.Region.Framework.Scenes
260 261
261 private void statsHeartBeat(object sender, EventArgs e) 262 private void statsHeartBeat(object sender, EventArgs e)
262 { 263 {
263 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22]; 264 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23];
264 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); 265 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
265 266
266 // Know what's not thread safe in Mono... modifying timers. 267 // Know what's not thread safe in Mono... modifying timers.
@@ -298,6 +299,35 @@ namespace OpenSim.Region.Framework.Scenes
298 physfps = 0; 299 physfps = 0;
299 300
300#endregion 301#endregion
302 float factor = 1 / m_statsUpdateFactor;
303
304 if (reportedFPS <= 0)
305 reportedFPS = 1;
306
307 float perframe = 1.0f / (float)reportedFPS;
308
309 float TotalFrameTime = m_frameMS * perframe;
310
311 float targetframetime = 1100.0f / (float)m_nominalReportedFps;
312
313 float sparetime;
314 float sleeptime;
315
316 if (TotalFrameTime > targetframetime)
317 {
318 sparetime = 0;
319 sleeptime = 0;
320 }
321 else
322 {
323 sparetime = m_frameMS - m_physicsMS - m_agentMS;
324 sparetime *= perframe;
325 if (sparetime < 0)
326 sparetime = 0;
327 else if (sparetime > TotalFrameTime)
328 sparetime = TotalFrameTime;
329 sleeptime = m_sleeptimeMS * perframe;
330 }
301 331
302 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); 332 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount();
303 m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); 333 m_childAgents = m_scene.SceneGraph.GetChildAgentCount();
@@ -309,25 +339,15 @@ namespace OpenSim.Region.Framework.Scenes
309 // so that stat numbers are always consistent. 339 // so that stat numbers are always consistent.
310 CheckStatSanity(); 340 CheckStatSanity();
311 341
312 //Our time dilation is 0.91 when we're running a full speed, 342 // other MS is actually simulation time
313 // therefore to make sure we get an appropriate range, 343 // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS;
314 // we have to factor in our error. (0.10f * statsUpdateFactor) 344 // m_imageMS m_netMS are not included in m_frameMS
315 // multiplies the fix for the error times the amount of times it'll occur a second
316 // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
317 // Then we divide the whole amount by the amount of seconds pass in between stats updates.
318 345
319 // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change 346 m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS;
320 // values to X-per-second values. 347 if (m_otherMS < 0)
348 m_otherMS = 0;
321 349
322 uint thisFrame = m_scene.Frame; 350 for (int i = 0; i < 23; i++)
323 float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor;
324 m_lastUpdateFrame = thisFrame;
325
326 // Avoid div-by-zero if somehow we've not updated any frames.
327 if (framesUpdated == 0)
328 framesUpdated = 1;
329
330 for (int i = 0; i < 22; i++)
331 { 351 {
332 sb[i] = new SimStatsPacket.StatBlock(); 352 sb[i] = new SimStatsPacket.StatBlock();
333 } 353 }
@@ -357,19 +377,19 @@ namespace OpenSim.Region.Framework.Scenes
357 sb[7].StatValue = m_activePrim; 377 sb[7].StatValue = m_activePrim;
358 378
359 sb[8].StatID = (uint)Stats.FrameMS; 379 sb[8].StatID = (uint)Stats.FrameMS;
360 sb[8].StatValue = m_frameMS / framesUpdated; 380 sb[8].StatValue = TotalFrameTime;
361 381
362 sb[9].StatID = (uint)Stats.NetMS; 382 sb[9].StatID = (uint)Stats.NetMS;
363 sb[9].StatValue = m_netMS / framesUpdated; 383 sb[9].StatValue = m_netMS * perframe;
364 384
365 sb[10].StatID = (uint)Stats.PhysicsMS; 385 sb[10].StatID = (uint)Stats.PhysicsMS;
366 sb[10].StatValue = m_physicsMS / framesUpdated; 386 sb[10].StatValue = m_physicsMS * perframe;
367 387
368 sb[11].StatID = (uint)Stats.ImageMS ; 388 sb[11].StatID = (uint)Stats.ImageMS ;
369 sb[11].StatValue = m_imageMS / framesUpdated; 389 sb[11].StatValue = m_imageMS * perframe;
370 390
371 sb[12].StatID = (uint)Stats.OtherMS; 391 sb[12].StatID = (uint)Stats.OtherMS;
372 sb[12].StatValue = m_otherMS / framesUpdated; 392 sb[12].StatValue = m_otherMS * perframe;
373 393
374 sb[13].StatID = (uint)Stats.InPacketsPerSecond; 394 sb[13].StatID = (uint)Stats.InPacketsPerSecond;
375 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); 395 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor);
@@ -381,7 +401,7 @@ namespace OpenSim.Region.Framework.Scenes
381 sb[15].StatValue = m_unAckedBytes; 401 sb[15].StatValue = m_unAckedBytes;
382 402
383 sb[16].StatID = (uint)Stats.AgentMS; 403 sb[16].StatID = (uint)Stats.AgentMS;
384 sb[16].StatValue = m_agentMS / framesUpdated; 404 sb[16].StatValue = m_agentMS * perframe;
385 405
386 sb[17].StatID = (uint)Stats.PendingDownloads; 406 sb[17].StatID = (uint)Stats.PendingDownloads;
387 sb[17].StatValue = m_pendingDownloads; 407 sb[17].StatValue = m_pendingDownloads;
@@ -396,7 +416,10 @@ namespace OpenSim.Region.Framework.Scenes
396 sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; 416 sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor;
397 417
398 sb[21].StatID = (uint)Stats.SimSpareMs; 418 sb[21].StatID = (uint)Stats.SimSpareMs;
399 sb[21].StatValue = m_spareMS / framesUpdated; 419 sb[21].StatValue = sparetime;
420
421 sb[22].StatID = (uint)Stats.SimSleepMs;
422 sb[22].StatValue = sleeptime;
400 423
401 for (int i = 0; i < 22; i++) 424 for (int i = 0; i < 22; i++)
402 { 425 {
@@ -429,13 +452,14 @@ namespace OpenSim.Region.Framework.Scenes
429 // Need to change things so that stats source can indicate whether they are per second or 452 // Need to change things so that stats source can indicate whether they are per second or
430 // per frame. 453 // per frame.
431 if (tuple.Key.EndsWith("MS")) 454 if (tuple.Key.EndsWith("MS"))
432 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated; 455 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframe;
433 else 456 else
434 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; 457 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor;
435 } 458 }
436 } 459 }
437 } 460 }
438 461
462// LastReportedObjectUpdates = m_objectUpdates / m_statsUpdateFactor;
439 ResetValues(); 463 ResetValues();
440 } 464 }
441 } 465 }
@@ -458,7 +482,8 @@ namespace OpenSim.Region.Framework.Scenes
458 m_physicsMS = 0; 482 m_physicsMS = 0;
459 m_imageMS = 0; 483 m_imageMS = 0;
460 m_otherMS = 0; 484 m_otherMS = 0;
461 m_spareMS = 0; 485// m_spareMS = 0;
486 m_sleeptimeMS = 0;
462 487
463//Ckrinke This variable is not used, so comment to remove compiler warning until it is used. 488//Ckrinke This variable is not used, so comment to remove compiler warning until it is used.
464//Ckrinke m_scriptMS = 0; 489//Ckrinke m_scriptMS = 0;
@@ -537,11 +562,6 @@ namespace OpenSim.Region.Framework.Scenes
537 m_frameMS += ms; 562 m_frameMS += ms;
538 } 563 }
539 564
540 public void AddSpareMS(int ms)
541 {
542 m_spareMS += ms;
543 }
544
545 public void addNetMS(int ms) 565 public void addNetMS(int ms)
546 { 566 {
547 m_netMS += ms; 567 m_netMS += ms;
@@ -567,6 +587,11 @@ namespace OpenSim.Region.Framework.Scenes
567 m_otherMS += ms; 587 m_otherMS += ms;
568 } 588 }
569 589
590 public void addSleepMS(int ms)
591 {
592 m_sleeptimeMS += ms;
593 }
594
570 public void AddPendingDownloads(int count) 595 public void AddPendingDownloads(int count)
571 { 596 {
572 m_pendingDownloads += count; 597 m_pendingDownloads += count;