org.limewire.statistic
Class AbstractKilobytesStatistic
java.lang.Object
org.limewire.statistic.AbstractStatistic
org.limewire.statistic.AbstractKilobytesStatistic
- All Implemented Interfaces:
- Inspectable, Statistic
- Direct Known Subclasses:
- BasicKilobytesStatistic
public abstract class AbstractKilobytesStatistic
- extends AbstractStatistic
Abstract class for recording data in kilobytes instead of bytes. In order to
preserve data accuracy, data is stored in bytes and converted to kilobytes;
otherwise, data would be lost.
A sample, aka a cycle of data, is all the data collected between calls to
AbstractStatistic.storeCurrentStat().
Therefore, the getMax() is the largest sample and the
getAverage() is the total size / the number of samples.
An example of using AbstractKilobytesStatistic:
class Stats extends AbstractKilobytesStatistic {}
Statistic s = new Stats();
for(int i = 0; i < 1024; i++)
s.incrementStat();
s.storeCurrentStat();
s.addData(2 * 1024);
s.storeCurrentStat();
s.addData(3 * 1024);
s.storeCurrentStat();
s.addData(4 * 1024);
s.storeCurrentStat();
s.addData(5 * 1024);
s.storeCurrentStat();
System.out.println("Total: " + s.getTotal());
System.out.println("Max: " + s.getMax());
System.out.println("Average: " + s.getAverage());
Output:
Total: 15.0
Max: 5.0
Average: 3.0
|
Method Summary |
double |
getAverage()
Overridden to report the average for this statistic in kilobyes. |
double |
getMax()
Overridden to report the maximum for this statistic in kilobyes. |
double |
getTotal()
Overridden to report the total for this statistic in kilobytes. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractKilobytesStatistic
public AbstractKilobytesStatistic()
getAverage
public double getAverage()
- Overridden to report the average for this statistic in kilobyes.
- Specified by:
getAverage in interface Statistic- Overrides:
getAverage in class AbstractStatistic
- Returns:
- the average for this statistic in kilobytes per unit of
measurement (KB/s)
getMax
public double getMax()
- Overridden to report the maximum for this statistic in kilobyes.
- Specified by:
getMax in interface Statistic- Overrides:
getMax in class AbstractStatistic
- Returns:
- the maximum for a recorded time period for this statistic
in kilobytes
getTotal
public double getTotal()
- Overridden to report the total for this statistic in kilobytes.
- Specified by:
getTotal in interface Statistic- Overrides:
getTotal in class AbstractStatistic
- Returns:
- the total for this statistic in kilobytes
Copyright © 2009. All Rights Reserved.