01: package com.jamonapi;
02:
03: /** The most basic of timing Monitors. It is very close in performance to making straight calls to System.currentTimeMillis().
04: * This class is used primarily for comparison to the best case performance numbers for all of the other Monitors,
05: * however it may also be used to make timing measurements.
06: *
07: * BasicTimingMonitors are not thread safe. Monitors returned via MonitorFactory are.
08: *
09: * Sample call:
10: * BasicTimingMonitor mon=new BasicTimingMonitor();
11: * mon.start();
12: * ...code being monitored...
13: * mon.stop();
14: **/
15:
16: final public class BasicTimingMonitor {
17: // Note. this class does not implement the Monitor interface and is not used in the
18: // rest of the monitor framework. However it can be used if performance comparable
19: // to simple times to currentTimeMillis() are required.
20: private long startTime;
21:
22: public void start() {
23: startTime = System.currentTimeMillis();
24: }
25:
26: public long stop() {
27: return System.currentTimeMillis() - startTime;
28: }
29: }
|