Anonymous avatar Anonymous committed 508bf13

Revert "Use CLOCK_MONOTONIC_RAW for System.nanoTime."

This reverts commit 7757924895a28a43ab9f7c3931cc9f972e870ddc.

Further investigation suggests this is a worse clock for our purposes, not the better one it would appear to be from the man page. It looks more like it should have been called CLOCK_TSC.

Change-Id: I6bf7fe4dac19272f145d240917129b4d5ab5ade1

Comments (0)

Files changed (2)


      * Returns the current timestamp of the most precise timer available on the
-     * local system, in nanoseconds. Equivalent to something like Linux's
-     * {@code CLOCK_MONOTONIC_RAW}.
+     * local system, in nanoseconds. Equivalent to Linux's {@code CLOCK_MONOTONIC}.
      * <p>This timestamp should only be used to measure a duration by comparing it
      * against another timestamp from the same process on the same device.


 static jlong System_nanoTime(JNIEnv*, jclass) {
     timespec now;
-    clock_gettime(CLOCK_MONOTONIC_RAW, &now);
-#else // Darwin, say.
-  clock_gettime(CLOCK_MONOTONIC, &now);
+    clock_gettime(CLOCK_MONOTONIC, &now);
     return now.tv_sec * 1000000000LL + now.tv_nsec;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.