|
LimeWire collection component api | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.limewire.collection.QueueCounter
public class QueueCounter
Measures the average number of elements in a queueing system.
See Little's Law for more information.
try{
QueueCounter qc = new QueueCounter(10);
System.out.println("Average size: " + qc.getAverageSize());
for(int i = 0; i < 10; i++){
qc.recordArrival();
Thread.sleep( 1000 );
}
for(int i = 0; i < 10; i++)
qc.recordDeparture();
System.out.println("Average size: " + qc.getAverageSize());
} catch(Exception e) {
e.printStackTrace();
}
Output:
Average size: -1.0
Average size: 5.500395106845166
| Constructor Summary | |
|---|---|
QueueCounter(int historySize)
|
|
| Method Summary | |
|---|---|
double |
getAverageSize()
|
boolean |
isStale()
|
void |
recordArrival()
Record an arrival in the system. |
void |
recordDeparture()
Record a departure from the system. |
void |
reset()
Forgets all recorded data. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public QueueCounter(int historySize)
| Method Detail |
|---|
public void recordArrival()
public void recordDeparture()
public double getAverageSize()
public boolean isStale()
1. we have enough historical data and 2. the system has been empty for longer than the period over which the historical data was recorded.Note that this is an arbitrary recommendation and may be completely irrelevant for some purposes.
public void reset()
|
LimeWire collection component api | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||