de.unihalle.informatik.MiToBo.tools.system
Class UserTime

java.lang.Object
  extended by de.unihalle.informatik.MiToBo.tools.system.UserTime

public class UserTime
extends java.lang.Object

This is a stopwatch to measure elapsed user or real time used.

If the proper native library is availabe and is requested user time is elapsed. Otherwith real time is elapsed. If you like to use this class you must set the VM option -Djava.library.path to the directory where the native library resides.
The native library is

Author:
Jens Keilwagen, modified: Stefan Posch

Field Summary
private static boolean debug
          For internal use.
(package private) static boolean haveJNI
          Were we able to load the JNI library?
(package private)  float start
          Variable to save start value.
(package private)  long startReal
          Variable to save real start value.
(package private)  float ticks
          Variable to remember ticks.
(package private) static java.lang.String timeLib
          Basename of the JNI library.
private  boolean useJNI
          Does this instance use JNI and thus user time?
 
Constructor Summary
UserTime()
          Creates a new time object and starts the clock.
UserTime(boolean useUsertime)
          Creates a new time object and starts the clock elapsing real time.
 
Method Summary
 double getElapsedTime()
          Returns the elapsed time since last reset (or invoking the constructor) in seconds
 java.lang.String getOperation()
          Return UserTime or RealTime depending on mode of operation
private  long getTicks()
          Declaration of native method for getting ticks.
private  float getUserTime()
          Declaration of native method for user time measurement.
 void reset()
          Reset time
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

private static boolean debug
For internal use.


haveJNI

static boolean haveJNI
Were we able to load the JNI library?


start

float start
Variable to save start value.


startReal

long startReal
Variable to save real start value.


ticks

float ticks
Variable to remember ticks.


timeLib

static final java.lang.String timeLib
Basename of the JNI library.


useJNI

private boolean useJNI
Does this instance use JNI and thus user time?

Constructor Detail

UserTime

public UserTime()
Creates a new time object and starts the clock. Elapses user time, if runtime library is available, otherwise the real time.


UserTime

public UserTime(boolean useUsertime)
Creates a new time object and starts the clock elapsing real time. Elapses user time, if useUsertime is true and the runtime library is available, otherwise the real time.

Method Detail

getElapsedTime

public double getElapsedTime()
Returns the elapsed time since last reset (or invoking the constructor) in seconds


getOperation

public java.lang.String getOperation()
Return UserTime or RealTime depending on mode of operation


getTicks

private long getTicks()
Declaration of native method for getting ticks.

Returns:
Ticks.

getUserTime

private float getUserTime()
Declaration of native method for user time measurement.

Returns:
Current user time.

reset

public void reset()
Reset time