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:
05: * This class is used primarily for comparison to the best case performance numbers for all of the other Monitors,
06:
07: * however it may also be used to make timing measurements.
08:
09: *
10:
11: * BasicTimingMonitors are not thread safe. Monitors returned via MonitorFactory are.
12:
13: *
14:
15: * Sample call:
16:
17: * BasicTimingMonitor mon=new BasicTimingMonitor();
18:
19: * mon.start();
20:
21: * ...code being monitored...
22:
23: * mon.stop();
24:
25: **/
26:
27: final public class BasicTimingMonitor {
28:
29: // Note. this class does not implement the Monitor interface and is not used in the
30:
31: // rest of the monitor framework. However it can be used if performance comparable
32:
33: // to simple times to currentTimeMillis() are required.
34:
35: private long startTime;
36:
37: public void start() {
38:
39: startTime = System.currentTimeMillis();
40:
41: }
42:
43: public long stop() {
44:
45: return System.currentTimeMillis() - startTime;
46:
47: }
48:
49: }
|