aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Monitoring/StatsManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Monitoring/StatsManager.cs')
-rw-r--r--OpenSim/Framework/Monitoring/StatsManager.cs35
1 files changed, 33 insertions, 2 deletions
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs
index 02df0ac..b5dc24f 100644
--- a/OpenSim/Framework/Monitoring/StatsManager.cs
+++ b/OpenSim/Framework/Monitoring/StatsManager.cs
@@ -153,9 +153,9 @@ namespace OpenSim.Framework.Monitoring
153 public string ShortName { get; private set; } 153 public string ShortName { get; private set; }
154 public string Name { get; private set; } 154 public string Name { get; private set; }
155 public string Description { get; private set; } 155 public string Description { get; private set; }
156 public string UnitName { get; private set; } 156 public virtual string UnitName { get; private set; }
157 157
158 public double Value { get; set; } 158 public virtual double Value { get; set; }
159 159
160 public Stat( 160 public Stat(
161 string shortName, string name, string unitName, string category, string container, StatVerbosity verbosity, string description) 161 string shortName, string name, string unitName, string category, string container, StatVerbosity verbosity, string description)
@@ -176,4 +176,35 @@ namespace OpenSim.Framework.Monitoring
176 return string.Format("{0}+{1}+{2}", container, category, shortName); 176 return string.Format("{0}+{1}+{2}", container, category, shortName);
177 } 177 }
178 } 178 }
179
180 public class PercentageStat : Stat
181 {
182 public int Antecedent { get; set; }
183 public int Consequent { get; set; }
184
185 public override double Value
186 {
187 get
188 {
189 int c = Consequent;
190
191 // Avoid any chance of a multi-threaded divide-by-zero
192 if (c == 0)
193 return 0;
194
195 return (double)Antecedent / c;
196 }
197
198 set
199 {
200 throw new Exception("Cannot set value on a PercentageStat");
201 }
202 }
203
204 public PercentageStat(
205 string shortName, string name, string category, string container, StatVerbosity verbosity, string description)
206 : base(shortName, name, " %", category, container, verbosity, description)
207 {
208 }
209 }
179} \ No newline at end of file 210} \ No newline at end of file