org.objectweb.proactive.benchmarks.timit.util
Class HierarchicalTimer

java.lang.Object
  extended by org.objectweb.proactive.benchmarks.timit.util.HierarchicalTimer
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
FakeTimer, SecuredHierarchicalTimer

public class HierarchicalTimer
extends java.lang.Object
implements java.io.Serializable

This class provide some methods to benchmark your applications.
Example of use : (TODO)
extends Timeable
Timer timer = new Timer();
timer.start(T_total);
timer.stop(T_total);
Stats stats = reduce(timer, rank, leader, groupSize);

Author:
Brian Amedro, Vladimir Bodnartchouk
See Also:
org.objectweb.proactive.benchmarks.timit.examples, Serialized Form

Field Summary
protected  java.lang.String[] counter_name
           
protected  int level
           
static int MAX_ENABLED_COUNTERS
           
protected  int[] parent
           
protected  int[] parentStarted
           
 
Constructor Summary
HierarchicalTimer()
          Create a timer with all counters enabled.
 
Method Summary
 void activateCounters(TimerCounter[] counters, TimItReductor tr)
          Invoked by TimIt to activate only specified counters
 void addInstance(HierarchicalTimer t)
          Adds a HierarchicalTimer instance to the arrayList.
 void addValue(int n, int time)
           
 java.lang.String getCounterName(int n)
          Get the name of counter from his id
protected static long getCtm()
          Get currentTimeMillis() maybe one day we will be able to enhanced this call...
 int getElapsedTime(int n)
          Returns the time in milliseconds elapsed since last start of this counter
 int getHierarchicalTime(int n)
          Returns the total time in milliseconds of this counter for this hierarchy
 int getNbCounter()
          Get the number of available counters
 HierarchicalTimerStatistics getStats()
          This function must be called after all timers were collected.
 int getTotalTime(int n)
          Returns the total time in milliseconds of this counter for all hierarchies
 boolean isStarted(int n)
          Know if a counter is started or not
static void printArray(double[][][] array, java.lang.String[] counterName, int n)
          Prints a 3dim array of doubles, suppose that array was initialized with -1d values.
 int readTimer(int i, int j, int k)
          Returns the value
 void resetCounter(int n)
          Reset only one counter
 void resetTimer()
          Reset the timing values
 void setValue(int n, int time)
           
 void start(int n)
          Starts a counter.
 void startAsync(int n)
           
 void stop(int n)
          Stops the adequate counter.
 void stopAsync(int n)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_ENABLED_COUNTERS

public static final int MAX_ENABLED_COUNTERS
See Also:
Constant Field Values

level

protected int level

parent

protected int[] parent

parentStarted

protected int[] parentStarted

counter_name

protected java.lang.String[] counter_name
Constructor Detail

HierarchicalTimer

public HierarchicalTimer()
Create a timer with all counters enabled. Note: Only MAX_ENABLED_COUNTERS can be enabled at a time

Method Detail

activateCounters

public void activateCounters(TimerCounter[] counters,
                             TimItReductor tr)
Invoked by TimIt to activate only specified counters

Parameters:
counters - the counters you want to specify
tr - the TimItReductor instance

resetTimer

public void resetTimer()
Reset the timing values


resetCounter

public void resetCounter(int n)
Reset only one counter

Parameters:
n - the counter id

addInstance

public void addInstance(HierarchicalTimer t)
Adds a HierarchicalTimer instance to the arrayList.

Parameters:
t - The HierarchicalTimer instance to add.

getNbCounter

public int getNbCounter()
Get the number of available counters

Returns:
the number of counters

getCounterName

public java.lang.String getCounterName(int n)
Get the name of counter from his id

Parameters:
n - the id of the counter
Returns:
the name of the counter

isStarted

public boolean isStarted(int n)
Know if a counter is started or not

Parameters:
n - the id of the counter
Returns:
true if started, false otherwise

start

public void start(int n)
Starts a counter.

Parameters:
n - The integer that idetifies the timer to stop.

startAsync

public void startAsync(int n)

stop

public void stop(int n)
Stops the adequate counter.

Parameters:
n - The integer that idetifies the timer to stop.

stopAsync

public void stopAsync(int n)

setValue

public void setValue(int n,
                     int time)

addValue

public void addValue(int n,
                     int time)

readTimer

public int readTimer(int i,
                     int j,
                     int k)
Returns the value


getElapsedTime

public int getElapsedTime(int n)
Returns the time in milliseconds elapsed since last start of this counter

Parameters:
n - the counter Id
Returns:
the elapsed time since start

getHierarchicalTime

public int getHierarchicalTime(int n)
Returns the total time in milliseconds of this counter for this hierarchy

Parameters:
n - the counter Id
Returns:
the total elapsed time for this hierarchy.

getTotalTime

public int getTotalTime(int n)
Returns the total time in milliseconds of this counter for all hierarchies

Parameters:
n - the counter Id
Returns:
the total time elapsed for this counter in all hierarchies

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
The description of the current hierarchical timer.

getStats

public HierarchicalTimerStatistics getStats()
This function must be called after all timers were collected.

Returns:
HierarchicalTimerStatistics An instance of stats class.

printArray

public static void printArray(double[][][] array,
                              java.lang.String[] counterName,
                              int n)
Prints a 3dim array of doubles, suppose that array was initialized with -1d values.

Parameters:
array - The 3 dim array of values to print.
counterName - The array of counter names.
n - The number of counters.

getCtm

protected static final long getCtm()
Get currentTimeMillis() maybe one day we will be able to enhanced this call... Note: no performances impact (verified)



Copyright 2001-2007 INRIA All Rights Reserved.