|
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()
public void reset()
|
LimeWire Collection Component API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||