Package org.basex.util
Class Performance
java.lang.Object
org.basex.util.Performance
This class contains methods for performance measurements.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringformat(long size) Returns a human-readable representation for the specified size value (b, kB, MB, ...).static voidgc(int count) Performs some garbage collection.static StringReturns a formatted representation of the current memory consumption.getTime()Returns the measured execution time in milliseconds and resets the timer.getTime(int runs) Returns the measured execution time in milliseconds, divided by the number of runs, and resets the timer.static StringgetTime(long nano, int runs) Returns a string with the measured execution time in milliseconds.static longmemory()Returns the current memory consumption in bytes.static doublems(long nano, int runs) Returns the measured execution time in nanoseconds and resets the timer.longns()Returns the measured execution time in nanoseconds and resets the timer.longns(boolean reset) Returns the measured execution time in nanoseconds.static voidsleep(long ms) Sleeps the specified number of milliseconds.toString()
-
Constructor Details
-
Performance
public Performance()
-
-
Method Details
-
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
Returns the measured execution time in milliseconds and resets the timer.- Returns:
- execution time
-
getTime
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
Returns a string with the measured execution time in milliseconds.- Parameters:
nano- measured time in nanosecondsruns- number of runs- Returns:
- execution time
-
getMemory
Returns a formatted representation of the current memory consumption.- Returns:
- memory consumption
-
format
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
-
toString
-