1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.commsen.stopwatch;
17
18 /***
19 * Simple class to wrap basic stopwatch methods. The only reason this class exists is to make happy
20 * those developers who prefer
21 *
22 * <code>
23 * <pre>
24 * .....
25 * Meter meter = Stopwatch.startMeter("group", "label");
26 * // some code to be measured
27 * meter.stop();
28 * ...
29 * </pre>
30 *</code>
31 *
32 * over
33 *
34 * <code>
35 * <pre>
36 * .....
37 * long swId = Stopwatch.start("group", "label");
38 * // some code to be measured
39 * Stopwatch.stop(swId);
40 * ...
41 * </pre>
42 *</code>
43 *
44 * although it does exactly the same thing.
45 *
46 * @author Milen Dyankov
47 * @since 0.4
48 */
49 public class Meter {
50
51 private final long id;
52
53
54 /***
55 * Creates new object wrapping the id returned by {@link Stopwatch#start(String, String)};
56 *
57 * @param id the stopwatch id
58 */
59 Meter(long id) {
60 this.id = id;
61 }
62
63
64 /***
65 * Simply forwards to {@link Stopwatch#stop(long)}
66 */
67 public void stop() {
68 Stopwatch.stop(id);
69 }
70
71
72 /***
73 * Simply forwards to {@link Stopwatch#skip(long)}
74 */
75 public void cancel() {
76 Stopwatch.skip(id);
77 }
78
79 }