Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-08-15 16:07:58 +0000
committerStijn Buys <ingar@osirion.org>2008-08-15 16:07:58 +0000
commitfa589fafa7f094bc1bf07642b55f3d824814adba (patch)
treedc1b96685c4d92cd838551ee14ce02a7f81eb5bf /src/core/timer.cc
parentb780874cf4ab23cf9e48aa23da2394169da24887 (diff)
moved Timer to core::
Diffstat (limited to 'src/core/timer.cc')
-rw-r--r--src/core/timer.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/core/timer.cc b/src/core/timer.cc
new file mode 100644
index 0000000..e5a808e
--- /dev/null
+++ b/src/core/timer.cc
@@ -0,0 +1,41 @@
+/*
+ core/timer.cc
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
+*/
+
+#include "core/timer.h"
+
+#include <unistd.h>
+#include <iostream>
+
+namespace core {
+
+Timer::Timer()
+{
+ gettimeofday(&this->timer_tick, &this->timer_tz);
+ this->timer_elapsed = 0;
+}
+
+Timer::~Timer()
+{
+}
+
+void Timer::mark()
+{
+ gettimeofday(&timer_tick, &timer_tz);
+}
+
+float Timer::elapsed()
+{
+ struct timeval tick;
+ struct timezone tick_tz;
+
+ gettimeofday(&tick, &tick_tz);
+
+ // calculate elapsed time in 10^-6 seconds
+ long delta = (tick.tv_sec - timer_tick.tv_sec) * 1000000 + (tick.tv_usec - timer_tick.tv_usec);
+ return( (float) delta / 1000000.0f);
+}
+
+}