public class Counter extends Object
Long.MIN_VALUE
Counts up to Long.MAX_VALUE - 1
starting at 0 and overflowing to 0.
Constructor and Description |
---|
Counter()
Creates a new counter up to
Long.MAX.VALUE - 1 |
Counter(long max)
Creates a new counter with the given max. value
|
Modifier and Type | Method and Description |
---|---|
long |
add(long delta)
Adds the given delta to the counter.
|
double |
getAvgPer(TimeUnit unit)
Computes the average raise per given unit of time.
|
long |
getCount()
Returns the current value of the counter
|
long |
getDuration(TimeUnit unit)
Returns the time since the counter was created.
|
long |
inc()
Increments the counter by one
|
void |
reset()
Resets the counter to zero
|
String |
toString() |
public Counter(long max)
max
- maximal value which will force to counter to overflow and reset to 0public Counter()
Long.MAX.VALUE - 1
public long inc()
public long add(long delta)
delta
- the delta to addpublic double getAvgPer(TimeUnit unit)
unit
- the unit of time to compute the average for.public long getCount()
public long getDuration(TimeUnit unit)
unit
- the time unit used for the return valuepublic void reset()
Copyright © 2018. All rights reserved.