mernen (owner)

Revisions

gist: 13163 Download_button fork
public
Public Clone URL: git://gist.github.com/13163.git
Embed All Files: show embed
Diff #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
diff --git a/vm/profiler.cpp b/vm/profiler.cpp
index 17353d2..05b13b6 100644
--- a/vm/profiler.cpp
+++ b/vm/profiler.cpp
@@ -19,8 +19,15 @@
 
 #else
 
-#define current_time() ((uint64_t)clock())
-#define METHOD "clock"
+uint64_t current_time() {
+ timespec tp;
+ if (clock_gettime(CLOCK_REALTIME, &tp)) {
+ // error! Do something about it?
+ return 0U;
+ }
+ return tp.tv_sec * 1000000000UL + tp.tv_nsec;
+}
+#define METHOD "clock_gettime"
 
 #endif
 
@@ -69,7 +76,7 @@ namespace rubinius {
 
       return time * timebase.numer / timebase.denom;
 #else
- return time / (CLOCKS_PER_SEC * 1000000000UL);
+ return time;
 #endif
 
     }