/* A restartable timer. start() and stop() work in the obvious way. reset() stops the timer and resets it to zero. in_ms() and in_seconds() read the current value of the timer (whether it is running or not). */ class Timer { private long time; private boolean running; public inline void reset() { time = 0; running = false; } public inline void start() { running = true; time -= System.currentTimeMillis(); } public inline void stop() { running = false; time += System.currentTimeMillis(); } public inline long in_ms() { return (running ? (System.currentTimeMillis() + time) : time); } public inline double in_seconds() { return in_ms() / 1000.0d; } }