public class Counter extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Counter.Type
An enumeration of all types of measurement supported
|
| Modifier and Type | Field and Description |
|---|---|
static TimeUnit |
DEFAULT_UNIT
The default time unit to be stored (nanoseconds) if no specific time unit informed
|
protected static String |
STRING_FORMAT |
| Constructor and Description |
|---|
Counter(Counter.Type type)
Builds this Counter object with default time unit of nanoseconds.
|
Counter(Counter.Type type,
TimeUnit timeUnit)
Builds this Counter object with the given type and time unit.
|
| Modifier and Type | Method and Description |
|---|---|
void |
after()
Set the units after with this counter's default data fetch strategy
|
void |
before()
Set the units before with this counter's default data fetch strategy
|
long |
elapsedTime() |
long |
elapsedTime(TimeUnit timeUnit)
Returns the elapsed time, in a given
TimeUnit. |
TimeUnit |
getDefaultTimeUnit() |
Counter.Type |
getType() |
long |
getUnitsAfter() |
long |
getUnitsBefore() |
void |
setUnitsAfter(long unitsAfter) |
void |
setUnitsBefore(long unitsBefore) |
String |
toString() |
protected static final String STRING_FORMAT
public static final TimeUnit DEFAULT_UNIT
public Counter(Counter.Type type)
This is equivalent to: new Counter(type, TimeUnit.NANOSECONDS}
type - the type to setpublic Counter(Counter.Type type, TimeUnit timeUnit)
type - the type to settimeUnit - the unit to setpublic long getUnitsBefore()
public void setUnitsBefore(long unitsBefore)
unitsBefore - the units to be setpublic long getUnitsAfter()
public void setUnitsAfter(long unitsAfter)
unitsAfter - the units to be setpublic Counter.Type getType()
public TimeUnit getDefaultTimeUnit()
public void before()
public void after()
public long elapsedTime()
public long elapsedTime(TimeUnit timeUnit)
TimeUnit.timeUnit - the time unit to which the elapsed time will be convertedCopyright © 2019. All rights reserved.