summaryrefslogtreecommitdiff
path: root/RTJava/benchmarks/RawSpeed/Fir/PerformanceMeter.java
blob: 508bc49a902f3a6d60cec0c68883295bf50a9574 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//$Id$

package Fir;

/**
 * This class provide a pretty easy and naive way of
 * measuring the performance of software, in term of
 * time taken to execute a given test. This class
 * represent the abstract base for class that effectively
 * preform some test. What this class provide is a template
 * method, that implements the logic related to the measuring
 * of the time ellapsed.
 */
public class PerformanceMeter {

    /**
     * This method runs the test by setting the start time
     * invoking the sublclass specific Run method.
     */
    public void Start() {
        this.mTimeTrace = new TimeTrace();
        this.mTimeTrace.Start();
        this.Run();
        this.mTimeTrace.Stop();
    }

    /**
     * Gives the time taken to run the test.
     */
    public double GetTraceTime() {
        return this.mTimeTrace.GetElapsedTime();
    }

    /**
     * Gets an estimate of the accuracy of the estimate given.
     */
    public double GetTraceTimeResolution() {
        return this.mTimeTrace.GetResolution();
    }

    /**
     * This method has to be filled by the sub-class
     * that provide a specific test strategy.
     */
    protected  void Run() { }

    private TimeTrace mTimeTrace;
}