public class NanoCounter extends Facultative implements NanoCounterMBean, LongCounter
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.atomic.AtomicLong |
count
Total number of calls
|
private java.util.concurrent.atomic.AtomicLong |
total
Total time
|
Constructor and Description |
---|
NanoCounter() |
Modifier and Type | Method and Description |
---|---|
long |
getCount()
Get the number of operations
|
long |
getTotalTimeMs()
Return total time in ms
|
long |
getTotalTimeNs()
Return total time in ns
|
void |
print(java.lang.String file)
Print counters' values to the file
|
void |
print(java.lang.String comment,
java.lang.String file)
Print counters' values to the file
|
void |
reset()
Reset counters
|
java.lang.String |
toString(java.lang.String ts,
java.lang.String comment)
Return the string representation of the counter
|
void |
update(long value)
Update counter
|
enable, getAnnotation, isEnabled, register, setAnnotation
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
enable, getAnnotation, isEnabled, setAnnotation
dump
private final java.util.concurrent.atomic.AtomicLong total
private final java.util.concurrent.atomic.AtomicLong count
public void reset()
reset
in interface NanoCounterMBean
public long getTotalTimeNs()
getTotalTimeNs
in interface NanoCounterMBean
public long getTotalTimeMs()
getTotalTimeMs
in interface NanoCounterMBean
public long getCount()
getCount
in interface NanoCounterMBean
public void update(long value)
update
in interface LongCounter
value
- new valuepublic void print(java.lang.String file) throws java.io.IOException
print
in interface NanoCounterMBean
file
- output file name (will be appended if exists)java.io.IOException
public void print(java.lang.String comment, java.lang.String file) throws java.io.IOException
comment
- commentfile
- output file name (will be appended if exists)java.io.IOException
public java.lang.String toString(java.lang.String ts, java.lang.String comment) throws java.io.IOException
toString
in interface LongCounter
ts
- comment
- commentjava.io.IOException