diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 02df0ac106..b5dc24f4ae 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs @@ -153,9 +153,9 @@ namespace OpenSim.Framework.Monitoring public string ShortName { get; private set; } public string Name { get; private set; } public string Description { get; private set; } - public string UnitName { get; private set; } + public virtual string UnitName { get; private set; } - public double Value { get; set; } + public virtual double Value { get; set; } public Stat( string shortName, string name, string unitName, string category, string container, StatVerbosity verbosity, string description) @@ -176,4 +176,35 @@ namespace OpenSim.Framework.Monitoring return string.Format("{0}+{1}+{2}", container, category, shortName); } } + + public class PercentageStat : Stat + { + public int Antecedent { get; set; } + public int Consequent { get; set; } + + public override double Value + { + get + { + int c = Consequent; + + // Avoid any chance of a multi-threaded divide-by-zero + if (c == 0) + return 0; + + return (double)Antecedent / c; + } + + set + { + throw new Exception("Cannot set value on a PercentageStat"); + } + } + + public PercentageStat( + string shortName, string name, string category, string container, StatVerbosity verbosity, string description) + : base(shortName, name, " %", category, container, verbosity, description) + { + } + } } \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index b7b5ea21d8..2addb5bab8 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -245,7 +245,7 @@ namespace OpenSim.Region.Framework.Scenes = new Stat( "SlowFrames", "Slow Frames", - "frames", + " frames", "scene", m_scene.Name, StatVerbosity.Info,