de.unkrig.commons.util
Class ThreadBenchmark

java.lang.Object
  extended by de.unkrig.commons.util.ThreadBenchmark

public class ThreadBenchmark
extends java.lang.Object

Measures real time, cpu time and user time for the current thread.


Constructor Summary
ThreadBenchmark()
           
 
Method Summary
 double getCpuTime()
          Returns the total CPU time for the current thread in seconds since this object was created.
 java.lang.String getMessage()
           
 double getRealTime()
           
 double getUserTime()
          Returns the CPU time that the current thread has executed in user mode in seconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadBenchmark

public ThreadBenchmark()
Method Detail

getRealTime

public double getRealTime()
Returns:
The real (clock) time in seconds since this object was created

getCpuTime

public double getCpuTime()
Returns the total CPU time for the current thread in seconds since this object was created. If the implementation distinguishes between user mode time and system mode time, the returned CPU time is the amount of time that the current thread has executed in user mode or system mode.

The return value is undefined if this object was created by a different thread.


getUserTime

public double getUserTime()
Returns the CPU time that the current thread has executed in user mode in seconds.

The return value is undefined if this object was created by a different thread.


getMessage

public java.lang.String getMessage()
Returns:
A nicely formatted string telling the real, cpu and user time since this object was created.