Class SystemTimer
- java.lang.Object
-
- biz.gabrys.maven.plugin.util.timer.SystemTimer
-
- All Implemented Interfaces:
Timer
public class SystemTimer extends Object implements Timer
Default implementation of the
Timer
which based on theSystem.currentTimeMillis()
method.Example:
public class ExampleMojo extends AbstractMojo { public void execute() {
Timer
timer =SystemTimer.getStartedTimer()
; // logic ... getLog().info("Finished in " + timer.stop()); } }- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description SystemTimer()
Constructs a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SystemTimer
getStartedTimer()
Returns a new started timer.TimeSpan
getTime()
Returns a current counted execution time.void
start()
Starts counting execution time.TimeSpan
stop()
Stops counting execution time.
-
-
-
Method Detail
-
start
public void start()
Description copied from interface:Timer
Starts counting execution time.
-
getTime
public TimeSpan getTime()
Returns a current counted execution time. The current counted time span is equal to:null
when timer has not been startedcurrent time - start time
when timer has been started and has not been stoppedcounted time during stop
when timer has been stopped
-
getStartedTimer
public static SystemTimer getStartedTimer()
Returns a new started timer.- Returns:
- the new timer.
- Since:
- 1.0
- See Also:
start()
-
-