aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SimStatsReporter.cs')
-rwxr-xr-x[-rw-r--r--]OpenSim/Region/Framework/Scenes/SimStatsReporter.cs123
1 files changed, 115 insertions, 8 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index 8f1e345..6182bcd 100644..100755
--- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
@@ -213,6 +213,27 @@ namespace OpenSim.Region.Framework.Scenes
213 213
214 private int m_objectCapacity = 45000; 214 private int m_objectCapacity = 45000;
215 215
216 // This is the number of frames that will be stored and then averaged for
217 // the Total, Simulation, Physics, and Network Frame Time; It is set to
218 // 10 by default but can be changed by the OpenSim.ini configuration file
219 // NumberOfFrames parameter
220 private int m_numberFramesStored = 10;
221
222 // The arrays that will hold the time it took to run the past N frames,
223 // where N is the num_frames_to_average given by the configuration file
224 private double[] m_totalFrameTimeMilliseconds;
225 private double[] m_simulationFrameTimeMilliseconds;
226 private double[] m_physicsFrameTimeMilliseconds;
227 private double[] m_networkFrameTimeMilliseconds;
228
229 // The location of the next time in milliseconds that will be
230 // (over)written when the next frame completes
231 private int m_nextLocation = 0;
232
233 // The correct number of frames that have completed since the last stats
234 // update for physics
235 private int m_numberPhysicsFrames;
236
216 private Scene m_scene; 237 private Scene m_scene;
217 238
218 private RegionInfo ReportingRegion; 239 private RegionInfo ReportingRegion;
@@ -223,6 +244,13 @@ namespace OpenSim.Region.Framework.Scenes
223 244
224 public SimStatsReporter(Scene scene) 245 public SimStatsReporter(Scene scene)
225 { 246 {
247 // Initialize the different frame time arrays to the correct sizes
248 m_totalFrameTimeMilliseconds = new double[m_numberFramesStored];
249 m_simulationFrameTimeMilliseconds = new
250 double[m_numberFramesStored];
251 m_physicsFrameTimeMilliseconds = new double[m_numberFramesStored];
252 m_networkFrameTimeMilliseconds = new double[m_numberFramesStored];
253
226 m_scene = scene; 254 m_scene = scene;
227 m_reportedFpsCorrectionFactor = scene.MinFrameSeconds * m_nominalReportedFps; 255 m_reportedFpsCorrectionFactor = scene.MinFrameSeconds * m_nominalReportedFps;
228 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000); 256 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000);
@@ -256,6 +284,13 @@ namespace OpenSim.Region.Framework.Scenes
256 StatsManager.RegisterStat(SlowFramesStat); 284 StatsManager.RegisterStat(SlowFramesStat);
257 } 285 }
258 286
287 public SimStatsReporter(Scene scene, int numberOfFrames) : this (scene)
288 {
289 // Store the number of frames from the OpenSim.ini configuration
290 // file
291 m_numberFramesStored = numberOfFrames;
292 }
293
259 public void Close() 294 public void Close()
260 { 295 {
261 m_report.Elapsed -= TriggerStatsHeartbeat; 296 m_report.Elapsed -= TriggerStatsHeartbeat;
@@ -289,6 +324,11 @@ namespace OpenSim.Region.Framework.Scenes
289 324
290 private void statsHeartBeat(object sender, EventArgs e) 325 private void statsHeartBeat(object sender, EventArgs e)
291 { 326 {
327 double totalSumFrameTime;
328 double simulationSumFrameTime;
329 double physicsSumFrameTime;
330 double networkSumFrameTime;
331
292 if (!m_scene.Active) 332 if (!m_scene.Active)
293 return; 333 return;
294 334
@@ -314,14 +354,21 @@ namespace OpenSim.Region.Framework.Scenes
314 354
315#region various statistic googly moogly 355#region various statistic googly moogly
316 356
357 // ORIGINAL code commented out until we have time to add our own
358 // statistics to the statistics window, this will be done as a
359 // new section given the title of our current project
317 // We're going to lie about the FPS because we've been lying since 2008. The actual FPS is currently 360 // We're going to lie about the FPS because we've been lying since 2008. The actual FPS is currently
318 // locked at a maximum of 11. Maybe at some point this can change so that we're not lying. 361 // locked at a maximum of 11. Maybe at some point this can change so that we're not lying.
319 int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor); 362 //int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor);
320 363 int reportedFPS = m_fps;
364
321 // save the reported value so there is something available for llGetRegionFPS 365 // save the reported value so there is something available for llGetRegionFPS
322 lastReportedSimFPS = reportedFPS / m_statsUpdateFactor; 366 lastReportedSimFPS = reportedFPS / m_statsUpdateFactor;
323 367
324 float physfps = ((m_pfps / 1000)); 368 // ORIGINAL code commented out until we have time to add our own
369 // statistics to the statistics window
370 //float physfps = ((m_pfps / 1000));
371 float physfps = m_numberPhysicsFrames;
325 372
326 //if (physfps > 600) 373 //if (physfps > 600)
327 //physfps = physfps - (physfps - 600); 374 //physfps = physfps - (physfps - 600);
@@ -364,6 +411,26 @@ namespace OpenSim.Region.Framework.Scenes
364 sb[i] = new SimStatsPacket.StatBlock(); 411 sb[i] = new SimStatsPacket.StatBlock();
365 } 412 }
366 413
414 // Resetting the sums of the frame times to prevent any errors
415 // in calculating the moving average for frame time
416 totalSumFrameTime = 0;
417 simulationSumFrameTime = 0;
418 physicsSumFrameTime = 0;
419 networkSumFrameTime = 0;
420
421 // Loop through all the frames that were stored for the current
422 // heartbeat to process the moving average of frame times
423 for (int i = 0; i < m_numberFramesStored; i++)
424 {
425 // Sum up each frame time in order to calculate the moving
426 // average of frame time
427 totalSumFrameTime += m_totalFrameTimeMilliseconds[i];
428 simulationSumFrameTime +=
429 m_simulationFrameTimeMilliseconds[i];
430 physicsSumFrameTime += m_physicsFrameTimeMilliseconds[i];
431 networkSumFrameTime += m_networkFrameTimeMilliseconds[i];
432 }
433
367 sb[0].StatID = (uint) Stats.TimeDilation; 434 sb[0].StatID = (uint) Stats.TimeDilation;
368 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); 435 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
369 436
@@ -388,21 +455,31 @@ namespace OpenSim.Region.Framework.Scenes
388 sb[7].StatID = (uint) Stats.ActivePrim; 455 sb[7].StatID = (uint) Stats.ActivePrim;
389 sb[7].StatValue = m_activePrim; 456 sb[7].StatValue = m_activePrim;
390 457
458 // ORIGINAL code commented out until we have time to add our own
459 // statistics to the statistics window
391 sb[8].StatID = (uint)Stats.FrameMS; 460 sb[8].StatID = (uint)Stats.FrameMS;
392 sb[8].StatValue = m_frameMS / framesUpdated; 461 //sb[8].StatValue = m_frameMS / framesUpdated;
462 sb[8].StatValue = (float) totalSumFrameTime /
463 m_numberFramesStored;
393 464
394 sb[9].StatID = (uint)Stats.NetMS; 465 sb[9].StatID = (uint)Stats.NetMS;
395 sb[9].StatValue = m_netMS / framesUpdated; 466 //sb[9].StatValue = m_netMS / framesUpdated;
467 sb[9].StatValue = (float) networkSumFrameTime /
468 m_numberFramesStored;
396 469
397 sb[10].StatID = (uint)Stats.PhysicsMS; 470 sb[10].StatID = (uint)Stats.PhysicsMS;
398 sb[10].StatValue = m_physicsMS / framesUpdated; 471 //sb[10].StatValue = m_physicsMS / framesUpdated;
472 sb[10].StatValue = (float) physicsSumFrameTime /
473 m_numberFramesStored;
399 474
400 sb[11].StatID = (uint)Stats.ImageMS ; 475 sb[11].StatID = (uint)Stats.ImageMS ;
401 sb[11].StatValue = m_imageMS / framesUpdated; 476 sb[11].StatValue = m_imageMS / framesUpdated;
402 477
403 sb[12].StatID = (uint)Stats.OtherMS; 478 sb[12].StatID = (uint)Stats.OtherMS;
404 sb[12].StatValue = m_otherMS / framesUpdated; 479 //sb[12].StatValue = m_otherMS / framesUpdated;
405 480 sb[12].StatValue = (float) simulationSumFrameTime /
481 m_numberFramesStored;
482
406 sb[13].StatID = (uint)Stats.InPacketsPerSecond; 483 sb[13].StatID = (uint)Stats.InPacketsPerSecond;
407 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); 484 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor);
408 485
@@ -475,6 +552,10 @@ namespace OpenSim.Region.Framework.Scenes
475 552
476 private void ResetValues() 553 private void ResetValues()
477 { 554 {
555 // Reset the number of frames that the physics library has
556 // processed since the last stats report
557 m_numberPhysicsFrames = 0;
558
478 m_timeDilation = 0; 559 m_timeDilation = 0;
479 m_fps = 0; 560 m_fps = 0;
480 m_pfps = 0; 561 m_pfps = 0;
@@ -605,6 +686,32 @@ namespace OpenSim.Region.Framework.Scenes
605 m_otherMS += ms; 686 m_otherMS += ms;
606 } 687 }
607 688
689 public void addPhysicsFrame(int frames)
690 {
691 // Add the number of physics frames to the correct total physics
692 // frames
693 m_numberPhysicsFrames += frames;
694 }
695
696 public void addFrameTimeMilliseconds(double total, double simulation,
697 double physics, double network)
698 {
699 // Save the frame times from the current frame into the appropriate
700 // arrays
701 m_totalFrameTimeMilliseconds[m_nextLocation] = total;
702 m_simulationFrameTimeMilliseconds[m_nextLocation] = simulation;
703 m_physicsFrameTimeMilliseconds[m_nextLocation] = physics;
704 m_networkFrameTimeMilliseconds[m_nextLocation] = network;
705
706 // Update to the next location in the list
707 m_nextLocation++;
708
709 // Since the list will begin to overwrite the oldest frame values
710 // first, the next location needs to loop back to the beginning of the
711 // list whenever it reaches the end
712 m_nextLocation = m_nextLocation % m_numberFramesStored;
713 }
714
608 public void AddPendingDownloads(int count) 715 public void AddPendingDownloads(int count)
609 { 716 {
610 m_pendingDownloads += count; 717 m_pendingDownloads += count;