diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2013-09-15 12:39:32 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2013-09-15 12:39:32 +0200 |
commit | bef7aff31e5ea073f0f160ca6a2f1e56b7dd881a (patch) | |
tree | 2f6122f682427322f925736e87a0bd68b658972c /FTNoIR_Tracker_PT/timer.h | |
parent | 3734ab61a6f0d4d8aad32a17a2eb5fc49245626e (diff) |
Initial PT 1.1 import
Codebase broken at this stage
Diffstat (limited to 'FTNoIR_Tracker_PT/timer.h')
-rw-r--r-- | FTNoIR_Tracker_PT/timer.h | 44 |
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..f189e23c --- /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 |