- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimer.java
More file actions
Latest commit
9 lines (8 loc) · 398 Bytes
/
Copy pathTimer.java
File metadata and controls
9 lines (8 loc) · 398 Bytes
1
2
3
4
5
6
7
8
9
// Crude wall clock timing utility, measuring time in seconds
classTimer {
privatelongstart = 0, spent = 0;
publicTimer() { play(); }
publicdoublecheck() { return (start==0 ? spent : System.nanoTime()-start+spent)/1e9; }
publicvoidpause() { if (start != 0) { spent += System.nanoTime()-start; start = 0; } }
publicvoidplay() { if (start == 0) start = System.nanoTime(); }
}