Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Unified Diff: samples/android_sample/jni/timer.cc

Issue 11434046: Android rayshader sample. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: samples/android_sample/jni/timer.cc
===================================================================
--- samples/android_sample/jni/timer.cc (revision 0)
+++ samples/android_sample/jni/timer.cc (revision 0)
@@ -0,0 +1,29 @@
+#include "timer.h"
+#include "bin/log.h"
+
+Timer::Timer() :
+ mElapsed(0.0f),
+ mLastTime(0.0) {
+}
+
+void Timer::reset() {
+ mElapsed = 0.0f;
+ mLastTime = now();
+}
+
+void Timer::update() {
+ double current = now();
+ mElapsed = (current - mLastTime);
+ mLastTime = current;
+}
+
+double Timer::now() {
+ timespec timeval;
+ clock_gettime(CLOCK_MONOTONIC, &timeval);
+ return timeval.tv_sec + (timeval.tv_nsec * 1.0e-9);
+}
+
+float Timer::elapsed() {
+ return mElapsed;
+}
+

Powered by Google App Engine
This is Rietveld 408576698