Package org.ojalgo.type
Class Stopwatch
- java.lang.Object
-
- org.ojalgo.type.Stopwatch
-
public class Stopwatch extends java.lang.Object
This stopwatch is always running. It start as soon as you create the instance.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Stopwatch.TimedResult<T>
-
Field Summary
Fields Modifier and Type Field Description private long
myStart
-
Constructor Summary
Constructors Constructor Description Stopwatch()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description long
countMillis()
long
countNanos()
boolean
isLessThan(CalendarDateDuration duration)
boolean
isLessThanMillis(long millis)
boolean
isLessThanNanos(long nanos)
boolean
isMoreThan(CalendarDateDuration duration)
boolean
isMoreThanMillis(long millis)
boolean
isMoreThanNanos(long nanos)
static CalendarDateDuration
meassure(java.lang.Runnable task)
Meassure task duration using this class' stopwatch functionality.static CalendarDateDuration
meassure(java.lang.Runnable task, CalendarDateUnit unit)
static <T> Stopwatch.TimedResult<T>
meassure(java.util.concurrent.Callable<T> task)
static <T> Stopwatch.TimedResult<T>
meassure(java.util.concurrent.Callable<T> task, CalendarDateUnit unit)
void
reset()
Reset the start-instantlong
reset(CalendarDateUnit unit)
Will reset the start-instant and return duration since it was last reset in the specified unit.CalendarDateDuration
restart()
CalendarDateDuration
restart(CalendarDateUnit unit)
CalendarDateDuration
stop()
This method can be called repeatedly without resetting (doesn't actually stop the timing process)CalendarDateDuration
stop(CalendarDateUnit unit)
-
-
-
Method Detail
-
meassure
public static <T> Stopwatch.TimedResult<T> meassure(java.util.concurrent.Callable<T> task)
-
meassure
public static <T> Stopwatch.TimedResult<T> meassure(java.util.concurrent.Callable<T> task, CalendarDateUnit unit)
-
meassure
public static CalendarDateDuration meassure(java.lang.Runnable task)
Meassure task duration using this class' stopwatch functionality.- Parameters:
task
- The task to meassure- Returns:
- The meassured duration
-
meassure
public static CalendarDateDuration meassure(java.lang.Runnable task, CalendarDateUnit unit)
-
countMillis
public long countMillis()
-
countNanos
public long countNanos()
-
isLessThan
public boolean isLessThan(CalendarDateDuration duration)
-
isLessThanMillis
public boolean isLessThanMillis(long millis)
-
isLessThanNanos
public boolean isLessThanNanos(long nanos)
-
isMoreThan
public boolean isMoreThan(CalendarDateDuration duration)
-
isMoreThanMillis
public boolean isMoreThanMillis(long millis)
-
isMoreThanNanos
public boolean isMoreThanNanos(long nanos)
-
reset
public void reset()
Reset the start-instant
-
reset
public long reset(CalendarDateUnit unit)
Will reset the start-instant and return duration since it was last reset in the specified unit.
-
restart
public CalendarDateDuration restart()
-
restart
public CalendarDateDuration restart(CalendarDateUnit unit)
-
stop
public CalendarDateDuration stop()
This method can be called repeatedly without resetting (doesn't actually stop the timing process)- Returns:
- The duration since instantiation or reset.
-
stop
public CalendarDateDuration stop(CalendarDateUnit unit)
-
-