aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Monitoring/StatsManager.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Monitoring/StatsManager.cs54
1 files changed, 23 insertions, 31 deletions
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs
index 8787ea0..30926d8 100644
--- a/OpenSim/Framework/Monitoring/StatsManager.cs
+++ b/OpenSim/Framework/Monitoring/StatsManager.cs
@@ -80,8 +80,7 @@ namespace OpenSim.Framework.Monitoring
80 + "'all' will show all statistics.\n" 80 + "'all' will show all statistics.\n"
81 + "A <category> name will show statistics from that category.\n" 81 + "A <category> name will show statistics from that category.\n"
82 + "A <category>.<container> name will show statistics from that category in that container.\n" 82 + "A <category>.<container> name will show statistics from that category in that container.\n"
83 + "More than one name can be given separated by spaces.\n" 83 + "More than one name can be given separated by spaces.\n",
84 + "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS",
85 HandleShowStatsCommand); 84 HandleShowStatsCommand);
86 85
87 console.Commands.AddCommand( 86 console.Commands.AddCommand(
@@ -91,7 +90,6 @@ namespace OpenSim.Framework.Monitoring
91 "show stats [list|all|(<category>[.<container>])+", 90 "show stats [list|all|(<category>[.<container>])+",
92 "Alias for 'stats show' command", 91 "Alias for 'stats show' command",
93 HandleShowStatsCommand); 92 HandleShowStatsCommand);
94
95 StatsLogger.RegisterConsoleCommands(console); 93 StatsLogger.RegisterConsoleCommands(console);
96 } 94 }
97 95
@@ -361,8 +359,8 @@ namespace OpenSim.Framework.Monitoring
361 /// <returns></returns> 359 /// <returns></returns>
362 public static bool RegisterStat(Stat stat) 360 public static bool RegisterStat(Stat stat)
363 { 361 {
364 SortedDictionary<string, SortedDictionary<string, Stat>> category = null, newCategory; 362 SortedDictionary<string, SortedDictionary<string, Stat>> category = null;
365 SortedDictionary<string, Stat> container = null, newContainer; 363 SortedDictionary<string, Stat> container = null;
366 364
367 lock (RegisteredStats) 365 lock (RegisteredStats)
368 { 366 {
@@ -372,22 +370,15 @@ namespace OpenSim.Framework.Monitoring
372 if (TryGetStatParents(stat, out category, out container)) 370 if (TryGetStatParents(stat, out category, out container))
373 return false; 371 return false;
374 372
375 // We take a copy-on-write approach here of replacing dictionaries when keys are added or removed. 373 if (container == null)
376 // This means that we don't need to lock or copy them on iteration, which will be a much more 374 container = new SortedDictionary<string, Stat>();
377 // common operation after startup.
378 if (container != null)
379 newContainer = new SortedDictionary<string, Stat>(container);
380 else
381 newContainer = new SortedDictionary<string, Stat>();
382 375
383 if (category != null) 376 if (category == null)
384 newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>(category); 377 category = new SortedDictionary<string, SortedDictionary<string, Stat>>();
385 else
386 newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>();
387 378
388 newContainer[stat.ShortName] = stat; 379 container[stat.ShortName] = stat;
389 newCategory[stat.Container] = newContainer; 380 category[stat.Container] = container;
390 RegisteredStats[stat.Category] = newCategory; 381 RegisteredStats[stat.Category] = category;
391 } 382 }
392 383
393 return true; 384 return true;
@@ -400,23 +391,24 @@ namespace OpenSim.Framework.Monitoring
400 /// <returns></returns> 391 /// <returns></returns>
401 public static bool DeregisterStat(Stat stat) 392 public static bool DeregisterStat(Stat stat)
402 { 393 {
403 SortedDictionary<string, SortedDictionary<string, Stat>> category = null, newCategory; 394 SortedDictionary<string, SortedDictionary<string, Stat>> category = null;
404 SortedDictionary<string, Stat> container = null, newContainer; 395 SortedDictionary<string, Stat> container = null;
405 396
406 lock (RegisteredStats) 397 lock (RegisteredStats)
407 { 398 {
408 if (!TryGetStatParents(stat, out category, out container)) 399 if (!TryGetStatParents(stat, out category, out container))
409 return false; 400 return false;
410 401
411 newContainer = new SortedDictionary<string, Stat>(container); 402 if(container != null)
412 newContainer.Remove(stat.ShortName); 403 {
413 404 container.Remove(stat.ShortName);
414 newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>(category); 405 if(category != null && container.Count == 0)
415 newCategory.Remove(stat.Container); 406 {
416 407 category.Remove(stat.Container);
417 newCategory[stat.Container] = newContainer; 408 if(category.Count == 0)
418 RegisteredStats[stat.Category] = newCategory; 409 RegisteredStats.Remove(stat.Category);
419 410 }
411 }
420 return true; 412 return true;
421 } 413 }
422 } 414 }