org.eclipse.test.performance
Class PerformanceMeter

java.lang.Object
  extended by org.eclipse.test.performance.PerformanceMeter
Direct Known Subclasses:
InternalPerformanceMeter, NullPerformanceMeter

public abstract class PerformanceMeter
extends java.lang.Object

A PerformanceMeter is used for doing repeated measurements of an arbitrary operation. The kind of measurement and the retrieval of the results remain internal to the implementation. Measurements can include time, CPU cycle and memory consumption. A PerformanceMeter is created using the method Performance.createPerformanceMeter(String). An operation is measured by calling start() before and stop() after that operation. The measurement can be repeated, for example, to let the VM warm up and to allow for statistical analysis afterwards. After measurements are done and before an analysis of the results can be made commit() has to be called. This allows for example to prepare the measurements for analysis or persist them. Performance.assertPerformance(PerformanceMeter) provides a default analysis of the measurements. After the PerformanceMeter is no longer used dispose() must be called. Example usage in a test case:

 public void testOpenEditor() {
        Performance perf= Performance.getDefault();
        PerformanceMeter performanceMeter= perf.createPerformanceMeter(perf.getDefaultScenarioId(this));
        try {
                for (int i= 0; i < 10; i++) {
                        performanceMeter.start();
                        openEditor();
                        performanceMeter.stop();
                        closeEditor();
                }
                performanceMeter.commit();
                perf.assertPerformance(performanceMeter);
        } finally {
                performanceMeter.dispose();
        }
 }
 
This class is not intended to be subclassed by clients.


Constructor Summary
PerformanceMeter()
           
 
Method Summary
abstract  void commit()
          Called exactly once after repeated measurements are done and before their analysis.
abstract  void dispose()
          Dispose associated resources.
abstract  void start()
          Called immediately before the operation to measure.
abstract  void stop()
          Called immediately after the operation to measure.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PerformanceMeter

public PerformanceMeter()
Method Detail

start

public abstract void start()
Called immediately before the operation to measure. Must be followed by a call to stop() before subsequent calls to this method or commit().


stop

public abstract void stop()
Called immediately after the operation to measure. Must be preceded by a call to start(), that follows any previous call to this method.


commit

public abstract void commit()
Called exactly once after repeated measurements are done and before their analysis. Afterwards start() and stop() must not be called.


dispose

public abstract void dispose()
Dispose associated resources. Clients must call this method exactly once. Afterwards no methods must be called on the performance meter.