Package org.basex.util
Class Performance
- java.lang.Object
-
- org.basex.util.Performance
-
public final class Performance extends Object
This class contains methods for performance measurements.- Author:
- BaseX Team 2005-23, BSD License, Christian Gruen
-
-
Constructor Summary
Constructors Constructor Description Performance()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
format(long size)
Returns a human-readable representation for the specified size value (b, kB, MB, ...).static void
gc(int count)
Performs some garbage collection.static String
getMemory()
Returns a formatted representation of the current memory consumption.String
getTime()
Returns the measured execution time in milliseconds and resets the timer.String
getTime(int runs)
Returns the measured execution time in milliseconds, divided by the number of runs, and resets the timer.static String
getTime(long nano, int runs)
Returns a string with the measured execution time in milliseconds.static long
memory()
Returns the current memory consumption in bytes.static double
ms(long nano, int runs)
Returns the measured execution time in nanoseconds and resets the timer.long
ns()
Returns the measured execution time in nanoseconds and resets the timer.long
ns(boolean reset)
Returns the measured execution time in nanoseconds.static void
sleep(long ms)
Sleeps the specified number of milliseconds.String
toString()
-
-
-
Method Detail
-
ns
public long ns()
Returns the measured execution time in nanoseconds and resets the timer.- Returns:
- execution time
-
ns
public long ns(boolean reset)
Returns the measured execution time in nanoseconds.- Parameters:
reset
- reset timer- Returns:
- execution time
-
getTime
public String getTime()
Returns the measured execution time in milliseconds and resets the timer.- Returns:
- execution time
-
getTime
public String getTime(int runs)
Returns the measured execution time in milliseconds, divided by the number of runs, and resets the timer.- Parameters:
runs
- number of runs- Returns:
- execution time
-
ms
public static double ms(long nano, int runs)
Returns the measured execution time in nanoseconds and resets the timer.- Parameters:
nano
- execution time in nanosecondsruns
- number of runs- Returns:
- execution time
-
getTime
public static String getTime(long nano, int runs)
Returns a string with the measured execution time in milliseconds.- Parameters:
nano
- measured time in nanosecondsruns
- number of runs- Returns:
- execution time
-
getMemory
public static String getMemory()
Returns a formatted representation of the current memory consumption.- Returns:
- memory consumption
-
format
public static String format(long size)
Returns a human-readable representation for the specified size value (b, kB, MB, ...).- Parameters:
size
- value to be formatted- Returns:
- formatted size value
-
sleep
public static void sleep(long ms)
Sleeps the specified number of milliseconds.- Parameters:
ms
- time in milliseconds to wait
-
gc
public static void gc(int count)
Performs some garbage collection. GC behavior in Java is a pretty complex task. Still, garbage collection can be forced by calling it several times.- Parameters:
count
- number of times to execute garbage collection
-
memory
public static long memory()
Returns the current memory consumption in bytes.- Returns:
- memory consumption
-
-