Skip to content

Commit 6d449dd

Browse files
committed
Safe guard time collector.
1 parent a7b7b50 commit 6d449dd

File tree

1 file changed

+9
-0
lines changed
  • edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/utils

1 file changed

+9
-0
lines changed

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/utils/TimeCollector.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@ public class TimeCollector {
1111

1212
private long collectedTime;
1313
private long start;
14+
private boolean started;
1415

1516
public void start() {
17+
assert !started : "Time colletor is already started.";
18+
started = true;
19+
1620
start = System.currentTimeMillis();
1721
}
1822

1923
public void stop() {
24+
assert started : "Trying to stop a time collector that isn't started.";
25+
started = false;
26+
2027
final long elapsed = System.currentTimeMillis() - start;
2128
collectedTime += elapsed;
2229
}
@@ -26,6 +33,8 @@ public long getCollectedTime() {
2633
}
2734

2835
public void clear() {
36+
assert !started : "Shouldn't clear a running time collector.";
37+
2938
collectedTime = 0;
3039
}
3140
}

0 commit comments

Comments
 (0)