Package de.galan.commons.util
Class Measure
- java.lang.Object
-
- de.galan.commons.util.Measure
-
public class Measure extends Object
Measures invokation of Runnables/Callables in milliseconds. Average of n-invocations can also be calculated (using the '.every(n)' builder method). A total can be logged using finish() on the Measure object. Thread-safe.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <V> Vcall(Callable<V> callable)Measure the invokation time of the given Callable.Measureevery(Integer iterations)If provided, the average on a single invokation will be calculated/logged after every n-iterations.voidfinish()This method can be called to print the total amount of time taken until that point in time.static Measuremeasure(String what)Builds a new Measure object to measure invokations of runnables/callables.voidrun(ExceptionalRunnable runnable)Measure the invokation time of the given ExceptionalRunnable.voidrunnable(Runnable runnable)Measure the invokation time of the given Runnable (without Exception).Measuretotal(boolean total)
-
-
-
Method Detail
-
measure
public static Measure measure(String what)
Builds a new Measure object to measure invokations of runnables/callables.
-
every
public Measure every(Integer iterations)
If provided, the average on a single invokation will be calculated/logged after every n-iterations.
-
finish
public void finish()
This method can be called to print the total amount of time taken until that point in time.
-
total
public Measure total(boolean total)
-
runnable
public void runnable(Runnable runnable)
Measure the invokation time of the given Runnable (without Exception).
-
run
public void run(ExceptionalRunnable runnable) throws Exception
Measure the invokation time of the given ExceptionalRunnable.- Throws:
Exception
-
-