aicas logo Jamaica 3.4 release 8

com.aicas.jamaica.lang
Class CpuTime

java.lang.Object
  extended by com.aicas.jamaica.lang.CpuTime

public class CpuTime
extends Object

CpuTime provides access to the CPU timer, i.e., it permits the measurement of the CPU time spent by single threads in the system.


Field Summary
static long CPU_RATE
          CPU speed in cycles per millisecond.
static boolean CPU_TIME_SUPPORTED
          Flag that is true iff on the target system CPU usage monitoring is supported.
 
Constructor Summary
CpuTime()
           
 
Method Summary
static void cycles2RelativeTime(long cycles, RelativeTime relTime)
          Convert a number of CPU cycles into a RelativeTime value.
static long getAccurateCpuTime(Thread t)
          get high resolution Java execution time of a given thread.
static long getCpuTime(Thread t)
          get high resolution Java execution time of a given thread.
static long getRawCpuTime()
          get raw high resolution time.
static long getTotalCpuTime(Thread t)
          get high resolution total execution time of given thread.
static boolean isAccurate()
          This functions returns true iff for the given system, accurate CPU cost monitoring is possible.
static long relativeTime2Cycles(RelativeTime relTime)
          Convert a positive relative time to a CPU cycles value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CPU_TIME_SUPPORTED

public static final boolean CPU_TIME_SUPPORTED
Flag that is true iff on the target system CPU usage monitoring is supported.


CPU_RATE

public static final long CPU_RATE
CPU speed in cycles per millisecond. This value is either set via property CPU_MHZ_PROPERTY, or determined via an OS specific means, or measured. This will be set to 0 if CPU_TIME_SUPPORTED is not true.

Constructor Detail

CpuTime

public CpuTime()
Method Detail

isAccurate

public static boolean isAccurate()
This functions returns true iff for the given system, accurate CPU cost monitoring is possible. If this is the case, then function getCpuTime and getTotalCpuTime will return the exact number of CPU cycles used by a given task. Otherwise, these functions will provide estimates only that may include time spend by non-Java threads that preempted the thread the time is requested for or blocking time.

Returns:
true iff accurate CPU time is supported. false on systems on which Jamaica does not support accurate CPU monitoring.

getAccurateCpuTime

public static long getAccurateCpuTime(Thread t)
get high resolution Java execution time of a given thread. If isAccurate()==true, this will be the exact number of CPU cycles used by this thread's Java or native code. If isAccurate()==false, this will return 0.

Parameters:
t - the Java thread for which the execution time is to be returned.
Returns:
the execution time in CPU cycles, 0 on systems on which Jamaica does not support accurate CPU monitoring.

getCpuTime

public static long getCpuTime(Thread t)
get high resolution Java execution time of a given thread. If isAccurate()==true, this will be the exact number of CPU cycles used by this thread's Java or native code. In this case, the result is the same as getTotalExecutionTime(t). If isAccurate()==false, this is the number or CPU cycles used by this thread for Java code only, excluding native code (since native code may block and then result in a large execution time) but including the execution time of any non-java thread that preempted this thread.

Parameters:
t - the Java thread for which the execution time is to be returned.
Returns:
the execution time in CPU cycles, 0 on systems that don't permit access to CPU cycle counter or if the thread is not alive any more.

getTotalCpuTime

public static long getTotalCpuTime(Thread t)
get high resolution total execution time of given thread. If isAccurate()==true, this will be the exact number of CPU cycles used by this thread's Java or native code. In this case, the result is the same as getExecutionTime(t). If isAccurate()==false, this is the number or CPU cycles used by this thread for Java code and native code including blocking time in native code and including the execution time of any non-java thread that preempted this thread.

Parameters:
t - the Java thread for which the execution time is to be returned.
Returns:
the execution time in CPU cycles, 0 on systems that don't permit access to CPU cycle counter or if the thread is not alive any more.

getRawCpuTime

public static long getRawCpuTime()
get raw high resolution time.

Returns:
the execution time in CPU cycles, 0 on systems that don't permit access to CPU cycle counter.

cycles2RelativeTime

public static void cycles2RelativeTime(long cycles,
                                       RelativeTime relTime)
Convert a number of CPU cycles into a RelativeTime value.

Parameters:
cycles - number of CPU cycles, must be >= 0.
relTime - (out!) will be set to the time interval that corresponds to the given number of cycles.

relativeTime2Cycles

public static long relativeTime2Cycles(RelativeTime relTime)
Convert a positive relative time to a CPU cycles value.

Parameters:
relTime - a positive relative time, must not be null.
Returns:
the corresponding number of CPU cycles.

aicas logo Jamaica 3.4 release 8

aicas GmbH, Karlsruhe - Germany    www.aicas.com
Copyright 2001-2009 aicas GmbH. All Rights Reserved.