org.basex.util
Class Performance

java.lang.Object
  extended by org.basex.util.Performance

public final class Performance
extends java.lang.Object

This class contains methods for performance measurements.

Author:
Workgroup DBIS, University of Konstanz 2005-08, ISC License, Christian Gruen

Constructor Summary
Performance()
          Constructor, initializing the performance timer.
 
Method Summary
static java.lang.String format(long size)
          Formats a number according to the binary size orders (KB, MB, ...).
static java.lang.String format(long size, boolean det)
          Formats a file size according to the binary size orders (KB, MB, ...).
static void gc(int n)
          Perform some garbage collection.
static java.lang.String getMem()
          Returns a formatted representation of the current memory consumption.
 long getTime()
          Returns the measured execution time in nanoseconds.
 java.lang.String getTimer()
          Returns the measured execution time in milliseconds and reinitializes the timer.
 java.lang.String getTimer(int runs)
          Returns the measured execution time in milliseconds, divided by the number of runs, and reinitializes the timer.
static java.lang.String getTimer(long time, int runs)
          Returns a string with the measured execution time in milliseconds.
 void initTimer()
          Initializes the timer.
static void sleep(long ms)
          Sleeps the specified number of milliseconds.
static void stack()
          Throws and catches an error to display the current stack.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Performance

public Performance()
Constructor, initializing the performance timer.

Method Detail

initTimer

public void initTimer()
Initializes the timer.


getTime

public long getTime()
Returns the measured execution time in nanoseconds.

Returns:
execution time

getTimer

public java.lang.String getTimer()
Returns the measured execution time in milliseconds and reinitializes the timer.

Returns:
execution time

getTimer

public java.lang.String getTimer(int runs)
Returns the measured execution time in milliseconds, divided by the number of runs, and reinitializes the timer.

Parameters:
runs - number of runs
Returns:
execution time

getTimer

public static java.lang.String getTimer(long time,
                                        int runs)
Returns a string with the measured execution time in milliseconds.

Parameters:
time - measured time in nanoseconds
runs - number of runs
Returns:
execution time

getMem

public static java.lang.String getMem()
Returns a formatted representation of the current memory consumption.

Returns:
memory consumption

format

public static java.lang.String format(long size)
Formats a number according to the binary size orders (KB, MB, ...).

Parameters:
size - value to be formatted
Returns:
formatted size value

format

public static java.lang.String format(long size,
                                      boolean det)
Formats a file size according to the binary size orders (KB, MB, ...).

Parameters:
size - file size
det - detailed suffix
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 n)
Perform some garbage collection. GC behavior in Java is a pretty complex task. Still, garbage collection can be forced by calling it several times.

Parameters:
n - number of times to execute garbage collection

stack

public static void stack()
Throws and catches an error to display the current stack.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object