summaryrefslogtreecommitdiff
path: root/src/Clock.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Clock.cxx')
-rw-r--r--src/Clock.cxx32
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;
+ }
+};
+
+}
+