summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_pt/timer.h
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-03-22 21:48:28 +0100
committerStanislaw Halik <sthalik@misaki.pl>2013-03-22 21:51:09 +0100
commit4f05cb2af239ca8471b77c9f1d1c32e8c4cd3abc (patch)
tree338d3891b0c7710558aea3820d42af6eedfb0af9 /ftnoir_tracker_pt/timer.h
parent4f00c4c74d213a37a4b1a3313e50ce2b4dd51271 (diff)
Remove .bat files, actually finish rename this time
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