[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/44411] New: System.nanoTime() is not independent of wall-
From: |
adamb at videx dot com |
Subject: |
[Bug classpath/44411] New: System.nanoTime() is not independent of wall-clock time |
Date: |
4 Jun 2010 00:12:15 -0000 |
On Linux, Classpath appears to implement the System.nanoTime() function using
the gettimeofday function (see java_lang_VMSystem.c). Since gettimeofday
returns a wall-clock time this makes it unreliable for measuring elapsed time,
(because the system clock could be changed by another process at any moment.
According to the Sun javadocs:
... This method can only be used to measure elapsed time and is not
related to any other notion of system or wall-clock time. The
value returned represents nanoseconds since some fixed but
arbitrary time ...
In short, gettimeofday is not appropriate for measuring elapsed time. Perhaps
the clock_gettime function would work
(http://www.tin.org/bin/man.cgi?section=3&topic=clock_gettime) or the getrusage
function.
--
Summary: System.nanoTime() is not independent of wall-clock time
Product: classpath
Version: 0.98
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: classpath
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: adamb at videx dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44411
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug classpath/44411] New: System.nanoTime() is not independent of wall-clock time,
adamb at videx dot com <=