[clfft] 18/128: timer implementation for OS X

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Oct 22 14:54:33 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository clfft.

commit e4063ef4541cd34951b25b38d429f199a15f8e14
Author: John Colvin <john.loughran.colvin at gmail.com>
Date:   Tue Aug 18 15:58:10 2015 +0100

    timer implementation for OS X
---
 src/client/client.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/client/client.h b/src/client/client.h
index 2c70aba..b4f3050 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -41,6 +41,29 @@ public:
     }
 };
 
+#elif defined(__APPLE__) || defined(__MACOSX)
+
+#include <mach/clock.h>
+#include <mach/mach.h>
+
+struct Timer
+{
+    clock_serv_t clock;
+    mach_timespec_t start, end;
+
+public:
+    Timer() { host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &clock); }
+    ~Timer() { mach_port_deallocate(mach_task_self(), clock); }
+
+    void Start() { clock_get_time(clock, &start); }
+    double Sample()
+    {
+        clock_get_time(clock, &end);
+        double time = 1000000000L * (end.tv_sec - start.tv_sec) + end.tv_nsec - start.tv_nsec;
+        return time * 1E-9;
+    }
+};
+
 #else
 
 #include <time.h>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/clfft.git



More information about the debian-science-commits mailing list