Package io.bhagat.util
Class Timer
- java.lang.Object
-
- io.bhagat.util.Timer
-
public class Timer extends java.lang.ObjectA class for timing calculations to test efficiency- Author:
- Bhagat
-
-
Field Summary
Fields Modifier and Type Field Description private longstartTime
-
Constructor Summary
Constructors Constructor Description Timer()creates a Timer object
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longelapsed()voidrestart()calls the start methodvoidstart()starts the timer by initializing the startTime to the current timestatic longtime(Function<java.lang.Void,java.lang.Void> function)times a function
-
-
-
Method Detail
-
start
public void start()
starts the timer by initializing the startTime to the current time
-
restart
public void restart()
calls the start method
-
elapsed
public long elapsed()
- Returns:
- the time elapsed in milliseconds since the timer started
-
time
public static long time(Function<java.lang.Void,java.lang.Void> function)
times a function- Parameters:
function- the function to time- Returns:
- the number of milliseconds elapsed
-
-