java.lang.Object
net.foxgenesis.util.MethodTimer
Utility class that check the amount of time it takes to run a method
- Author:
- Ashley
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleTime how long it takes to executeRunnabler.static doublestatic StringTime how long it takes to executeRunnabler.static StringrunFormatMS(Runnable r, int decimals) Time how long it takes to executeRunnabler.static StringrunFormatMS(Runnable r, int n, int decimals)
-
Constructor Details
-
MethodTimer
public MethodTimer()
-
-
Method Details
-
run
Time how long it takes to executeRunnabler. Time is calculated in nano seconds and returned as milliseconds.- Parameters:
r- -Runnableto time- Returns:
- elapsed time in milliseconds
- See Also:
-
run
Time how long it takes to executeRunnabler,namount of times. Then calculate the average elapsed time taken.- Parameters:
r- -Runnableto timen- - Amount of times to run- Returns:
- average elapsed time milliseconds
- See Also:
-
runFormatMS
Time how long it takes to executeRunnabler. Time is calculated in nano seconds and returned as a formatted string with two decimal places.This method is effectively equivalent to
MethodTimer.runFormatMS(r, 2)
- Parameters:
r- -Runnableto time- Returns:
- formatted string with two decimal places
- See Also:
-
runFormatMS
Time how long it takes to executeRunnabler. Time is calculated in nano seconds and returned as a formatted string withdecimalsdecimal places.This method is effectively equivalent to
String.format("%." + decimals + "f ms", run(r))- Parameters:
r- -Runnableto timedecimals- - Amount of decimal places to format- Returns:
- formatted string with
decimalsdecimal places - See Also:
-
runFormatMS
Time the average elapsed time it takes to executeRunnabler,namount of times. Time is calculated in nano seconds and returned as a formatted string withdecimalsdecimal places.This method is effectively equivalent to
String.format("%." + decimals + "f ms", run(r, n));- Parameters:
r- -Runnableto timen- - Amount of times to executerdecimals- - Amount of decimal places to format- Returns:
- formatted string with
decimalsdecimal places - See Also:
-