[clfft] 50/74: timer for OSX

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Jan 14 19:52:17 UTC 2016


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

ghisvail-guest pushed a commit to branch debian/sid
in repository clfft.

commit d0b2ab619d07cb32a50e0eaccddb3a23103b6b4a
Author: Dominique Orban <dominique.orban at gmail.com>
Date:   Thu Dec 31 10:46:05 2015 -0500

    timer for OSX
    
    OSX lacks CLOCK_MONOTONIC
---
 src/callback-client/client.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/callback-client/client.h b/src/callback-client/client.h
index 474456a..79d260d 100644
--- a/src/callback-client/client.h
+++ b/src/callback-client/client.h
@@ -105,6 +105,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