Created
June 29, 2012 13:18
-
-
Save Xophmeister/3017860 to your computer and use it in GitHub Desktop.
Just a silly little timer!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio, core.time; | |
class msTimer { | |
TickDuration start; | |
this() { reset(); } | |
long split() { return (TickDuration.currSystemTick() - start).msecs(); } | |
void reset() { start = TickDuration.currSystemTick(); } | |
} | |
void wait(long ms) { | |
auto waiter = new msTimer(); | |
while(waiter.split() < ms) {}; | |
} | |
void main() { | |
auto stopWatch = new msTimer(); | |
writeln("Current split: ", stopWatch.split(), "ms"); | |
wait(2500); | |
writeln("Current split: ", stopWatch.split(), "ms"); | |
stopWatch.reset(); | |
writeln("Current split: ", stopWatch.split(), "ms"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment