diff options
author | Denis Oliver Kropp <dok@directfb.org> | 2010-10-19 15:56:15 +0200 |
---|---|---|
committer | Denis Oliver Kropp <dok@directfb.org> | 2010-10-19 15:56:15 +0200 |
commit | 27d1e03d7bdf8fcfe7292c06e40bc3e2fca9158e (patch) | |
tree | efee63b09d2f9b73e2ae73a9448660a3cf73c4e6 /src/Clock.cxx | |
download | pluggit-27d1e03d7bdf8fcfe7292c06e40bc3e2fca9158e.tar.gz pluggit-27d1e03d7bdf8fcfe7292c06e40bc3e2fca9158e.tar.bz2 pluggit-27d1e03d7bdf8fcfe7292c06e40bc3e2fca9158e.zip |
pluggit
Diffstat (limited to 'src/Clock.cxx')
-rw-r--r-- | src/Clock.cxx | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/Clock.cxx b/src/Clock.cxx new file mode 100644 index 0000000..bacf373 --- /dev/null +++ b/src/Clock.cxx @@ -0,0 +1,32 @@ +namespace PluggIt { + +class Clock +{ + private long long base; + private char str[20]; + + public Clock() { + Reset(); + } + + public void Reset() { + base = direct_clock_get_micros(); + } + + public float GetTime() { + return (direct_clock_get_micros() - base) / 1000000.0f; + } + + public const char *GetString() { + float time = GetTime(); + int seconds = (int) time; + int minutes = seconds / 60; + + snprintf( str, sizeof(str), "%02d:%02d", minutes, seconds ); + + return str; + } +}; + +} + |