back to index     prev     next  

0.2 Timer for the Benchmarks

In this API, it is the benchmark programmer who make the measure, he can simply use : System.currentTimeMillis() of Java. This method is in the wrong !

If you want to change the method to make measure you must to modify the code of all your Benchmarks.

The solution

To solve this problem, we have choose an interface : Timeable


package testsuite.timer;

public interface Timeable {
    // Start the timer
    public void start();

    // Stop the timer
    public void stop();

    // Get the total time, measured
    public long getCumulatedTime();

    // To print the time unit
    public String getUnit();
}
    

By default the API provides two timer which of implement this interface :

To make measure in milliseconds : testsuite.timer.ms.MsTimer

To make measure in microseconds : testsuite.timer.micro.MicroTimer

By implementing the interface you can easily create new timer for more performents for you needs.

How to use Timer in Benchmarck ?

Use this.timer like this :


public long action() throws Exception {
        String className = ReifiableObject.class.getName();
        Node node = getNode();
        this.timer.start();
        object = (ReifiableObject) ProActive.newActive(className, null, node);
        this.timer.stop();
        return this.timer.getCumulatedTime();
    }
    

How to configure the Manager with your Timer ?

By a prop file or a XML file :


	<prop key="Timer" value="testsuite.timer.micro.MicroTimer"/>
	
	Timer=testsuite.timer.micro.MicroTimer
    

Or by the code :


	yourManager.setTimer("class.name.YourTimer");