-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWordToVecTimer.java
More file actions
47 lines (38 loc) · 1.12 KB
/
WordToVecTimer.java
File metadata and controls
47 lines (38 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
/**
* WordToVecTimer is a simple little timer class, written so no external library is needed to do this.
*
* @author hulles
*
*/
final class WordToVecTimer {
private final static Level LOGLEVEL = Level.INFO;
private final static Map<String, Long> timerMap;
private WordToVecTimer() {
// only static methods, no need to instantiate it
}
static {
timerMap = new HashMap<String, Long>();
}
static void startTimer(String timerName) {
SharedUtils.checkNotNull(timerName);
timerMap.put(timerName, System.currentTimeMillis());
}
static Long stopTimer(String timerName) {
Long endTime;
Long startTime;
Long elapsedMillis;
SharedUtils.checkNotNull(timerName);
endTime = System.currentTimeMillis();
startTime = timerMap.remove(timerName);
if (startTime == null) {
System.err.println("Bad map start time in WordToVecTimer");
return null;
}
elapsedMillis = endTime - startTime;
SharedUtils.log(LOGLEVEL, "Timer " + timerName + ": " + SharedUtils.formatElapsedMillis(elapsedMillis));
return elapsedMillis;
}
}