public class TimerManager extends Object
Timer.
In TimerManager, timers are identified by name. Timers with the same name are merged into the same group to support aggregation function. Besides, it contains a series of methods to manage the lifecycle of timer.
| Constructor and Description |
|---|
TimerManager() |
| Modifier and Type | Method and Description |
|---|---|
static Long |
agg(String name,
TimerAggregation function)
Get the aggregation value of a group of timers.
|
static Long |
agg(TimerAggregation function)
Get the aggregation value of the default group of timers.
|
static Timer |
create()
Create a timer with an empty name and start after creation.
|
static Timer |
create(String name)
Create a timer with a given name and start after creation.
|
static Timer |
createWithoutStart(String name)
Create a timer with a given name.
|
static String |
format()
Format the time with the default name into human readable style .
|
static String |
format(long time)
Format the time with the specified name into human readable style .
|
static String |
format(String name)
Format the time with the specified name into human readable style .
|
static Timer |
getFirstTimer()
Get the oldest created timer with the default name.
|
static Timer |
getFirstTimer(String name)
Get the oldest created timer with the specified name.
|
static Timer |
getLastTimer()
Get the newest created timer with the default name.
|
static Timer |
getLastTimer(String name)
Get the newest created timer with the specified name.
|
static List<Timer> |
getTimerGroup()
Get the group of timers with the default name.
|
static List<Timer> |
getTimerGroup(String name)
Get the group of timers with the specified name.
|
static Timer |
start()
Start a timer with the default name
EMPTY_NAME. |
static Timer |
start(String name)
Start a timer with the specified name.
|
static Timer |
stop()
Stop a timer with the default name
EMPTY_NAME. |
static Timer |
stop(String name)
Stop a timer with the specified name.
|
static Long |
time()
Get recorded time of a timer with the default name.
|
static Long |
time(String name)
Get recorded time of a timer with the specified name.
|
public static Timer create()
public static Timer create(String name)
name - the name of timerpublic static Timer createWithoutStart(String name)
name - the name of timerpublic static Timer start()
EMPTY_NAME.public static Timer start(String name)
name - the specified namepublic static Timer stop()
EMPTY_NAME.public static Timer stop(String name)
name - the specified namepublic static Long time()
public static Long time(String name)
name - the specified namepublic static String format()
The default format is HH:mm:ss.SSS
public static String format(String name)
The default format is HH:mm:ss.SSS
name - the specified namepublic static String format(long time)
The default format is HH:mm:ss.SSS
time - the timepublic static Timer getLastTimer()
public static Timer getLastTimer(String name)
name - the specified namepublic static Timer getFirstTimer()
public static Timer getFirstTimer(String name)
name - the specified namepublic static List<Timer> getTimerGroup()
public static List<Timer> getTimerGroup(String name)
name - the specified namepublic static Long agg(TimerAggregation function)
function - aggregation function defined in TimerAggregationpublic static Long agg(String name, TimerAggregation function)
name - the specified name of groupfunction - aggregation function defined in TimerAggregationCopyright © 2019. All rights reserved.