aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs
diff options
context:
space:
mode:
authorAdam Frisby2008-05-01 16:35:00 +0000
committerAdam Frisby2008-05-01 16:35:00 +0000
commit13526097f24b7a8ad63b1d482c44b44397fa055f (patch)
tree7a82c20ed7c63e2aea5ad3863325e37f64e1cbea /OpenSim/Region/Environment/Scenes/SimStatsReporter.cs
parent* Breaking all the code, breaking all the code..! (diff)
downloadopensim-SC-13526097f24b7a8ad63b1d482c44b44397fa055f.zip
opensim-SC-13526097f24b7a8ad63b1d482c44b44397fa055f.tar.gz
opensim-SC-13526097f24b7a8ad63b1d482c44b44397fa055f.tar.bz2
opensim-SC-13526097f24b7a8ad63b1d482c44b44397fa055f.tar.xz
* Spring cleaning on Region.Environment.
* Converted a large number of read-only fields to be actually, readonly. * Reformatted code sections. * Removed redundant code.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Scenes/SimStatsReporter.cs274
1 files changed, 139 insertions, 135 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs
index a53bfcd..1f02f23 100644
--- a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs
@@ -34,105 +34,68 @@ namespace OpenSim.Region.Environment.Scenes
34{ 34{
35 public class SimStatsReporter 35 public class SimStatsReporter
36 { 36 {
37 public delegate void SendStatResult(SimStatsPacket pack); 37 #region Delegates
38
39 public event SendStatResult OnSendStatsResult;
40
41 private SendStatResult handlerSendStatResult = null;
42 38
43 private enum Stats : uint 39 public delegate void SendStatResult(SimStatsPacket pack);
44 {
45 TimeDilation = 0,
46 SimFPS = 1,
47 PhysicsFPS = 2,
48 AgentUpdates = 3,
49 FrameMS = 4,
50 NetMS = 5,
51 OtherMS = 6,
52 PhysicsMS = 7,
53 AgentMS = 8,
54 ImageMS = 9,
55 ScriptMS = 10,
56 TotalPrim = 11,
57 ActivePrim = 12,
58 Agents = 13,
59 ChildAgents = 14,
60 ActiveScripts = 15,
61 ScriptLinesPerSecond = 16,
62 InPacketsPerSecond = 17,
63 OutPacketsPerSecond = 18,
64 PendingDownloads = 19,
65 PendingUploads = 20,
66 UnAckedBytes = 24,
67 40
68 // Havok4 related... May or may not be in upcoming LLclients 41 #endregion
69 // (kelly added them sometime late in January 2008)
70 NumRCCSLODReduced = 25,
71 NumRCCSFixed = 26
72 }
73 42
74 // Sending a stats update every 3 seconds 43 private readonly Timer m_report = new Timer();
75 private int statsUpdatesEveryMS = 3000; 44 private readonly SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
76 private float statsUpdateFactor = 0; 45 private readonly RegionInfo ReportingRegion;
77 private float m_timeDilation = 0; 46 private readonly SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21];
78 private int m_fps = 0; 47 private readonly SimStatsPacket statpack = (SimStatsPacket) PacketPool.Instance.GetPacket(PacketType.SimStats);
79 private float m_pfps = 0; 48
80 private int m_agentUpdates = 0; 49 private SendStatResult handlerSendStatResult;
81 50 private int m_activePrim;
82 private int m_frameMS = 0; 51 private int m_activeScripts;
83 private int m_netMS = 0; 52 private int m_agentMS;
84 private int m_agentMS = 0; 53
85 private int m_physicsMS = 0; 54 private int m_agentUpdates;
86 private int m_imageMS = 0; 55 private int m_childAgents;
87 private int m_otherMS = 0; 56 private int m_fps;
88 57
89//Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. 58 private int m_frameMS;
90//Ckrinke private int m_scriptMS = 0; 59 private int m_imageMS;
91 60 private int m_inPacketsPerSecond;
92 private int m_rootAgents = 0; 61 private int m_netMS;
93 private int m_childAgents = 0; 62 private int m_numPrim;
94 private int m_numPrim = 0; 63 private int m_otherMS;
95 private int m_inPacketsPerSecond = 0; 64 private int m_outPacketsPerSecond;
96 private int m_outPacketsPerSecond = 0; 65 private int m_pendingDownloads;
97 private int m_activePrim = 0; 66 private int m_pendingUploads;
98 private int m_unAckedBytes = 0; 67 private float m_pfps;
99 private int m_pendingDownloads = 0; 68 private int m_physicsMS;
100 private int m_pendingUploads = 0; 69 private int m_rootAgents;
101 private int m_activeScripts = 0; 70 private int m_scriptLinesPerSecond;
102 private int m_scriptLinesPerSecond = 0; 71 private float m_timeDilation;
72 private int m_unAckedBytes;
103 73
104 private int objectCapacity = 45000; 74 private int objectCapacity = 45000;
105 75 private float statsUpdateFactor;
106 76 private int statsUpdatesEveryMS = 3000;
107 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[21];
108 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
109 SimStatsPacket statpack = (SimStatsPacket)PacketPool.Instance.GetPacket(PacketType.SimStats);
110
111
112 private RegionInfo ReportingRegion;
113
114 private Timer m_report = new Timer();
115 77
116 78
117 public SimStatsReporter(RegionInfo regionData) 79 public SimStatsReporter(RegionInfo regionData)
118 { 80 {
119 81 statsUpdateFactor = (statsUpdatesEveryMS / 1000);
120 statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000);
121 ReportingRegion = regionData; 82 ReportingRegion = regionData;
122 for (int i = 0; i<21;i++) 83 for (int i = 0; i < 21; i++)
123 { 84 {
124 sb[i] = new SimStatsPacket.StatBlock(); 85 sb[i] = new SimStatsPacket.StatBlock();
125 } 86 }
126 m_report.AutoReset = true; 87 m_report.AutoReset = true;
127 m_report.Interval = statsUpdatesEveryMS; 88 m_report.Interval = statsUpdatesEveryMS;
128 m_report.Elapsed += new ElapsedEventHandler(statsHeartBeat); 89 m_report.Elapsed += statsHeartBeat;
129 m_report.Enabled = true; 90 m_report.Enabled = true;
130 } 91 }
131 92
93 public event SendStatResult OnSendStatsResult;
94
132 public void SetUpdateMS(int ms) 95 public void SetUpdateMS(int ms)
133 { 96 {
134 statsUpdatesEveryMS = ms; 97 statsUpdatesEveryMS = ms;
135 statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); 98 statsUpdateFactor = (statsUpdatesEveryMS / 1000);
136 m_report.Interval = statsUpdatesEveryMS; 99 m_report.Interval = statsUpdatesEveryMS;
137 } 100 }
138 101
@@ -143,8 +106,8 @@ namespace OpenSim.Region.Environment.Scenes
143 lock (m_report) 106 lock (m_report)
144 { 107 {
145 // Packet is already initialized and ready for data insert 108 // Packet is already initialized and ready for data insert
146 109
147 110
148 statpack.Region = rb; 111 statpack.Region = rb;
149 statpack.Region.RegionX = ReportingRegion.RegionLocX; 112 statpack.Region.RegionX = ReportingRegion.RegionLocX;
150 statpack.Region.RegionY = ReportingRegion.RegionLocY; 113 statpack.Region.RegionY = ReportingRegion.RegionLocY;
@@ -154,102 +117,102 @@ namespace OpenSim.Region.Environment.Scenes
154 } 117 }
155 catch (Exception) 118 catch (Exception)
156 { 119 {
157 statpack.Region.RegionFlags = (uint) 0; 120 statpack.Region.RegionFlags = 0;
158 } 121 }
159 statpack.Region.ObjectCapacity = (uint) objectCapacity; 122 statpack.Region.ObjectCapacity = (uint) objectCapacity;
160 123
161#region various statistic googly moogly 124 #region various statistic googly moogly
162 125
163 // Our FPS is actually 10fps, so multiplying by 5 to get the amount that people expect there 126 // Our FPS is actually 10fps, so multiplying by 5 to get the amount that people expect there
164 // 0-50 is pretty close to 0-45 127 // 0-50 is pretty close to 0-45
165 float simfps = (int) ((m_fps * 5)); 128 float simfps = ((m_fps * 5));
166 129
167 //if (simfps > 45) 130 //if (simfps > 45)
168 //simfps = simfps - (simfps - 45); 131 //simfps = simfps - (simfps - 45);
169 //if (simfps < 0) 132 //if (simfps < 0)
170 //simfps = 0; 133 //simfps = 0;
171 134
172 // 135 //
173 float physfps = ((m_pfps / 1000)); 136 float physfps = ((m_pfps / 1000));
174 137
175 //if (physfps > 600) 138 //if (physfps > 600)
176 //physfps = physfps - (physfps - 600); 139 //physfps = physfps - (physfps - 600);
177 140
178 if (physfps < 0) 141 if (physfps < 0)
179 physfps = 0; 142 physfps = 0;
180 143
181#endregion 144 #endregion
182 145
183 //Our time dilation is 0.91 when we're running a full speed, 146 //Our time dilation is 0.91 when we're running a full speed,
184 // therefore to make sure we get an appropriate range, 147 // therefore to make sure we get an appropriate range,
185 // we have to factor in our error. (0.10f * statsUpdateFactor) 148 // we have to factor in our error. (0.10f * statsUpdateFactor)
186 // multiplies the fix for the error times the amount of times it'll occur a second 149 // multiplies the fix for the error times the amount of times it'll occur a second
187 // / 10 divides the value by the number of times the sim heartbeat runs (10fps) 150 // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
188 // Then we divide the whole amount by the amount of seconds pass in between stats updates. 151 // Then we divide the whole amount by the amount of seconds pass in between stats updates.
189 152
190 sb[0].StatID = (uint) Stats.TimeDilation; 153 sb[0].StatID = (uint) Stats.TimeDilation;
191 sb[0].StatValue = m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); 154 sb[0].StatValue = m_timeDilation; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
192 155
193 sb[1].StatID = (uint) Stats.SimFPS; 156 sb[1].StatID = (uint) Stats.SimFPS;
194 sb[1].StatValue = simfps/statsUpdateFactor; 157 sb[1].StatValue = simfps / statsUpdateFactor;
195 158
196 sb[2].StatID = (uint) Stats.PhysicsFPS; 159 sb[2].StatID = (uint) Stats.PhysicsFPS;
197 sb[2].StatValue = physfps / statsUpdateFactor; 160 sb[2].StatValue = physfps / statsUpdateFactor;
198 161
199 sb[3].StatID = (uint) Stats.AgentUpdates; 162 sb[3].StatID = (uint) Stats.AgentUpdates;
200 sb[3].StatValue = (m_agentUpdates / statsUpdateFactor); 163 sb[3].StatValue = (m_agentUpdates / statsUpdateFactor);
201 164
202 sb[4].StatID = (uint) Stats.Agents; 165 sb[4].StatID = (uint) Stats.Agents;
203 sb[4].StatValue = m_rootAgents; 166 sb[4].StatValue = m_rootAgents;
204 167
205 sb[5].StatID = (uint) Stats.ChildAgents; 168 sb[5].StatID = (uint) Stats.ChildAgents;
206 sb[5].StatValue = m_childAgents; 169 sb[5].StatValue = m_childAgents;
207 170
208 sb[6].StatID = (uint) Stats.TotalPrim; 171 sb[6].StatID = (uint) Stats.TotalPrim;
209 sb[6].StatValue = m_numPrim; 172 sb[6].StatValue = m_numPrim;
210 173
211 sb[7].StatID = (uint) Stats.ActivePrim; 174 sb[7].StatID = (uint) Stats.ActivePrim;
212 sb[7].StatValue = m_activePrim; 175 sb[7].StatValue = m_activePrim;
213 176
214 sb[8].StatID = (uint)Stats.FrameMS; 177 sb[8].StatID = (uint) Stats.FrameMS;
215 sb[8].StatValue = m_frameMS / statsUpdateFactor; 178 sb[8].StatValue = m_frameMS / statsUpdateFactor;
216 179
217 sb[9].StatID = (uint)Stats.NetMS; 180 sb[9].StatID = (uint) Stats.NetMS;
218 sb[9].StatValue = m_netMS / statsUpdateFactor; 181 sb[9].StatValue = m_netMS / statsUpdateFactor;
219 182
220 sb[10].StatID = (uint)Stats.PhysicsMS; 183 sb[10].StatID = (uint) Stats.PhysicsMS;
221 sb[10].StatValue = m_physicsMS / statsUpdateFactor; 184 sb[10].StatValue = m_physicsMS / statsUpdateFactor;
222 185
223 sb[11].StatID = (uint)Stats.ImageMS ; 186 sb[11].StatID = (uint) Stats.ImageMS;
224 sb[11].StatValue = m_imageMS / statsUpdateFactor; 187 sb[11].StatValue = m_imageMS / statsUpdateFactor;
225 188
226 sb[12].StatID = (uint)Stats.OtherMS; 189 sb[12].StatID = (uint) Stats.OtherMS;
227 sb[12].StatValue = m_otherMS / statsUpdateFactor; 190 sb[12].StatValue = m_otherMS / statsUpdateFactor;
228 191
229 sb[13].StatID = (uint)Stats.InPacketsPerSecond; 192 sb[13].StatID = (uint) Stats.InPacketsPerSecond;
230 sb[13].StatValue = (m_inPacketsPerSecond); 193 sb[13].StatValue = (m_inPacketsPerSecond);
231 194
232 sb[14].StatID = (uint)Stats.OutPacketsPerSecond; 195 sb[14].StatID = (uint) Stats.OutPacketsPerSecond;
233 sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor); 196 sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor);
234 197
235 sb[15].StatID = (uint)Stats.UnAckedBytes; 198 sb[15].StatID = (uint) Stats.UnAckedBytes;
236 sb[15].StatValue = m_unAckedBytes; 199 sb[15].StatValue = m_unAckedBytes;
237 200
238 sb[16].StatID = (uint)Stats.AgentMS; 201 sb[16].StatID = (uint) Stats.AgentMS;
239 sb[16].StatValue = m_agentMS / statsUpdateFactor; 202 sb[16].StatValue = m_agentMS / statsUpdateFactor;
240 203
241 sb[17].StatID = (uint)Stats.PendingDownloads; 204 sb[17].StatID = (uint) Stats.PendingDownloads;
242 sb[17].StatValue = m_pendingDownloads; 205 sb[17].StatValue = m_pendingDownloads;
243 206
244 sb[18].StatID = (uint)Stats.PendingUploads; 207 sb[18].StatID = (uint) Stats.PendingUploads;
245 sb[18].StatValue = m_pendingUploads; 208 sb[18].StatValue = m_pendingUploads;
246 209
247 sb[19].StatID = (uint)Stats.ActiveScripts; 210 sb[19].StatID = (uint) Stats.ActiveScripts;
248 sb[19].StatValue = m_activeScripts; 211 sb[19].StatValue = m_activeScripts;
249 212
250 sb[20].StatID = (uint)Stats.ScriptLinesPerSecond; 213 sb[20].StatID = (uint) Stats.ScriptLinesPerSecond;
251 sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor; 214 sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor;
252 215
253 statpack.Stat = sb; 216 statpack.Stat = sb;
254 217
255 handlerSendStatResult = OnSendStatsResult; 218 handlerSendStatResult = OnSendStatsResult;
@@ -260,7 +223,7 @@ namespace OpenSim.Region.Environment.Scenes
260 resetvalues(); 223 resetvalues();
261 } 224 }
262 } 225 }
263 226
264 private void resetvalues() 227 private void resetvalues()
265 { 228 {
266 m_timeDilation = 0; 229 m_timeDilation = 0;
@@ -284,6 +247,7 @@ namespace OpenSim.Region.Environment.Scenes
284 } 247 }
285 248
286 # region methods called from Scene 249 # region methods called from Scene
250
287 // The majority of these functions are additive 251 // The majority of these functions are additive
288 // so that you can easily change the amount of 252 // so that you can easily change the amount of
289 // seconds in between sim stats updates 253 // seconds in between sim stats updates
@@ -292,10 +256,10 @@ namespace OpenSim.Region.Environment.Scenes
292 { 256 {
293 //float tdsetting = td; 257 //float tdsetting = td;
294 //if (tdsetting > 1.0f) 258 //if (tdsetting > 1.0f)
295 //tdsetting = (tdsetting - (tdsetting - 0.91f)); 259 //tdsetting = (tdsetting - (tdsetting - 0.91f));
296 260
297 //if (tdsetting < 0) 261 //if (tdsetting < 0)
298 //tdsetting = 0.0f; 262 //tdsetting = 0.0f;
299 m_timeDilation = td; 263 m_timeDilation = td;
300 } 264 }
301 265
@@ -353,30 +317,35 @@ namespace OpenSim.Region.Environment.Scenes
353 { 317 {
354 m_frameMS += ms; 318 m_frameMS += ms;
355 } 319 }
320
356 public void addNetMS(int ms) 321 public void addNetMS(int ms)
357 { 322 {
358 m_netMS += ms; 323 m_netMS += ms;
359 } 324 }
325
360 public void addAgentMS(int ms) 326 public void addAgentMS(int ms)
361 { 327 {
362 m_agentMS += ms; 328 m_agentMS += ms;
363 } 329 }
330
364 public void addPhysicsMS(int ms) 331 public void addPhysicsMS(int ms)
365 { 332 {
366 m_physicsMS += ms; 333 m_physicsMS += ms;
367 } 334 }
335
368 public void addImageMS(int ms) 336 public void addImageMS(int ms)
369 { 337 {
370 m_imageMS += ms; 338 m_imageMS += ms;
371 } 339 }
340
372 public void addOtherMS(int ms) 341 public void addOtherMS(int ms)
373 { 342 {
374 m_otherMS += ms; 343 m_otherMS += ms;
375 } 344 }
376 345
377// private static readonly log4net.ILog m_log 346// private static readonly log4net.ILog m_log
378// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 347// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
379 348
380 public void addPendingDownload(int count) 349 public void addPendingDownload(int count)
381 { 350 {
382 m_pendingDownloads += count; 351 m_pendingDownloads += count;
@@ -399,5 +368,40 @@ namespace OpenSim.Region.Environment.Scenes
399 } 368 }
400 369
401 #endregion 370 #endregion
371
372 #region Nested type: Stats
373
374 private enum Stats : uint
375 {
376 TimeDilation = 0,
377 SimFPS = 1,
378 PhysicsFPS = 2,
379 AgentUpdates = 3,
380 FrameMS = 4,
381 NetMS = 5,
382 OtherMS = 6,
383 PhysicsMS = 7,
384 AgentMS = 8,
385 ImageMS = 9,
386 ScriptMS = 10,
387 TotalPrim = 11,
388 ActivePrim = 12,
389 Agents = 13,
390 ChildAgents = 14,
391 ActiveScripts = 15,
392 ScriptLinesPerSecond = 16,
393 InPacketsPerSecond = 17,
394 OutPacketsPerSecond = 18,
395 PendingDownloads = 19,
396 PendingUploads = 20,
397 UnAckedBytes = 24,
398
399 // Havok4 related... May or may not be in upcoming LLclients
400 // (kelly added them sometime late in January 2008)
401 NumRCCSLODReduced = 25,
402 NumRCCSFixed = 26
403 }
404
405 #endregion
402 } 406 }
403} 407} \ No newline at end of file