summaryrefslogtreecommitdiffhomepage
path: root/FTNoIR_Tracker_PT/timer.h
diff options
context:
space:
mode:
authorPatrick Ruoff <c14-radioactive@19e81ba0-9b1a-49c3-bd6c-561e1906d5fb>2012-12-31 12:33:18 +0000
committerPatrick Ruoff <c14-radioactive@19e81ba0-9b1a-49c3-bd6c-561e1906d5fb>2012-12-31 12:33:18 +0000
commit4c95700fc6848d46a33b565df7eb81ada2b32987 (patch)
treea0f13e7a70f2e22516b9fae6177e7e8b7af269fe /FTNoIR_Tracker_PT/timer.h
parent977f25772f449e79089059820453bb7499ff4d35 (diff)
Updated PointTracker
git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@200 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
Diffstat (limited to 'FTNoIR_Tracker_PT/timer.h')
-rw-r--r--FTNoIR_Tracker_PT/timer.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/FTNoIR_Tracker_PT/timer.h b/FTNoIR_Tracker_PT/timer.h
new file mode 100644
index 00000000..2aaf725a
--- /dev/null
+++ b/FTNoIR_Tracker_PT/timer.h
@@ -0,0 +1,44 @@
+/* Copyright (c) 2012 Patrick Ruoff
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ */
+
+#ifndef PT_TIMER_H
+#define PT_TIMER_H
+
+#ifdef WIN32 // Windows system specific
+#include <windows.h>
+#else // Unix based system specific
+#include <sys/time.h>
+#endif
+
+// ----------------------------------------------------------------------------
+// high resolution timer based on http://www.songho.ca/misc/timer/timer.html
+class Timer
+{
+public:
+ Timer();
+
+ void start();
+ void stop();
+ void restart() { start(); } // for Qt compatibility
+ double elapsed(); // get elapsed time in ms
+
+protected:
+ double startTime; // starting time in ms
+ double endTime; // ending time in ms
+ bool running;
+
+#ifdef WIN32
+ LARGE_INTEGER frequency; // ticks per second
+ LARGE_INTEGER startCount;
+ LARGE_INTEGER endCount;
+#else
+ timeval startCount;
+ timeval endCount;
+#endif
+};
+
+#endif //PT_TIMER_H \ No newline at end of file