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 Stringformat(long time, int decimals, double div) NEED_JAVADOCstatic StringformatToMilli(long time) NEED_JAVADOCstatic StringformatToMilli(long time, int decimals) NEED_JAVADOCstatic StringformatToSeconds(long time) NEED_JAVADOCstatic StringformatToSeconds(long time, int decimals) NEED_JAVADOCstatic 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) static StringTime how long it takes to executeRunnabler.static StringrunFormatSec(Runnable r, int decimals) Time how long it takes to executeRunnabler.static StringrunFormatSec(Runnable r, int n, int decimals) static double
-
Constructor Details
-
MethodTimer
public MethodTimer()
-
-
Method Details
-
runNano
-
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:
-
runFormatSec
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:
-
runFormatSec
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:
-
runFormatSec
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:
-
formatToMilli
NEED_JAVADOC- Parameters:
time-- Returns:
- formatted string
-
formatToMilli
NEED_JAVADOC- Parameters:
time-decimals-- Returns:
- formatted string
-
formatToSeconds
NEED_JAVADOC- Parameters:
time-- Returns:
- formatted string
-
formatToSeconds
NEED_JAVADOC- Parameters:
time-decimals-- Returns:
- formatted string
-
format
NEED_JAVADOC- Parameters:
time-decimals-div-- Returns:
- formatted string
-