From 27d1e03d7bdf8fcfe7292c06e40bc3e2fca9158e Mon Sep 17 00:00:00 2001 From: Denis Oliver Kropp Date: Tue, 19 Oct 2010 15:56:15 +0200 Subject: pluggit --- src/Clock.cxx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/Clock.cxx (limited to 'src/Clock.cxx') 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; + } +}; + +} + -- cgit