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-21, BSD License, Christian Gruen
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    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
    Returns a formatted representation of the current memory consumption.
    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 String
    getTime(long nano, int runs)
    Returns a string with the measured execution time in milliseconds.
    static long
    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.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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

      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 nanoseconds
      runs - 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 nanoseconds
      runs - 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
    • toString

      public String toString()
      Overrides:
      toString in class Object