|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
SystemClockStopwatch.java | 100% | 100% | 100% | 100% |
|
1 |
/*
|
|
2 |
* Copyright (C) 1998, 2003 Gargoyle Software. All rights reserved.
|
|
3 |
*
|
|
4 |
* This file is part of GSBase. For details on use and redistribution
|
|
5 |
* please refer to the license.html file included with these sources.
|
|
6 |
*/
|
|
7 |
package com.diasparsoftware.gsbase;
|
|
8 |
|
|
9 |
/**
|
|
10 |
* An production-quality implementation of
|
|
11 |
* com.gargoylesoftware.base.util.Stopwatch
|
|
12 |
* that uses the system clock.
|
|
13 |
*
|
|
14 |
* @version $Revision: 1.1 $
|
|
15 |
* @author <a href="mailto:jbr@diasparsoftware.com">J. B. Rainsberger</a>
|
|
16 |
*/
|
|
17 |
public class SystemClockStopwatch implements Stopwatch { |
|
18 |
private boolean started = false; |
|
19 |
private long startTime = -1; |
|
20 |
|
|
21 |
private boolean stopped; |
|
22 |
private long stopTime = -1; |
|
23 |
|
|
24 | 385 |
public void start() { |
25 | 385 |
startTime = System.currentTimeMillis(); |
26 | 385 |
started = true;
|
27 |
} |
|
28 |
|
|
29 | 374 |
public void stop() { |
30 | 374 |
stopped = true;
|
31 | 374 |
stopTime = System.currentTimeMillis(); |
32 |
} |
|
33 |
|
|
34 | 22 |
public void reset() { |
35 | 22 |
started = false;
|
36 | 22 |
stopped = false;
|
37 |
} |
|
38 |
|
|
39 | 55 |
public long getLastTime() { |
40 | 55 |
if (started && stopped) {
|
41 | 11 |
return stopTime - startTime;
|
42 |
} |
|
43 |
else {
|
|
44 | 44 |
return 0;
|
45 |
} |
|
46 |
} |
|
47 |
} |
|
48 |
|
|