CVSROOT: /cvsroot/classpath Module name: classpath Changes by: Andrew John Hughes <gnu_andrew> 06/06/04 18:15:05
Modified files: . : ChangeLog java/lang : System.java Log message: 2006-03-20 Andrew John Hughes <[EMAIL PROTECTED]> * java/lang/System.java: (nanoTime()): Documented. 2006-03-20 Tom Tromey <[EMAIL PROTECTED]> * java/lang/System.java: (nanoTime()): Implemented. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.7647&r2=1.7648 http://cvs.savannah.gnu.org/viewcvs/classpath/java/lang/System.java?cvsroot=classpath&r1=1.57&r2=1.58 Patches: Index: ChangeLog =================================================================== RCS file: /cvsroot/classpath/classpath/ChangeLog,v retrieving revision 1.7647 retrieving revision 1.7648 diff -u -b -r1.7647 -r1.7648 --- ChangeLog 4 Jun 2006 17:59:12 -0000 1.7647 +++ ChangeLog 4 Jun 2006 18:15:04 -0000 1.7648 @@ -1,3 +1,13 @@ +2006-03-20 Andrew John Hughes <[EMAIL PROTECTED]> + + * java/lang/System.java: + (nanoTime()): Documented. + +2006-03-20 Tom Tromey <[EMAIL PROTECTED]> + + * java/lang/System.java: + (nanoTime()): Implemented. + 2006-03-01 Anthony Balkissoon <[EMAIL PROTECTED]> * java/math/BigDecimal.java: Index: java/lang/System.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/lang/System.java,v retrieving revision 1.57 retrieving revision 1.58 diff -u -b -r1.57 -r1.58 --- java/lang/System.java 12 May 2006 15:54:38 -0000 1.57 +++ java/lang/System.java 4 Jun 2006 18:15:05 -0000 1.58 @@ -223,6 +223,36 @@ } /** + * <p> + * Returns the current value of a nanosecond-precise system timer. + * The value of the timer is an offset relative to some arbitrary fixed + * time, which may be in the future (making the value negative). This + * method is useful for timing events where nanosecond precision is + * required. This is achieved by calling this method before and after the + * event, and taking the difference betweent the two times: + * </p> + * <p> + * <code>long startTime = System.nanoTime();</code><br /> + * <code>... <emph>event code</emph> ...</code><br /> + * <code>long endTime = System.nanoTime();</code><br /> + * <code>long duration = endTime - startTime;</code><br /> + * </p> + * <p> + * Note that the value is only nanosecond-precise, and not accurate; there + * is no guarantee that the difference between two values is really a + * nanosecond. Also, the value is prone to overflow if the offset + * exceeds 2^63. + * </p> + * + * @return the time of a system timer in nanoseconds. + * @since 1.5 + */ + public static long nanoTime() + { + return VMSystem.nanoTime(); + } + + /** * Copy one array onto another from <code>src[srcStart]</code> ... * <code>src[srcStart+len-1]</code> to <code>dest[destStart]</code> ... * <code>dest[destStart+len-1]</code>. First, the arguments are validated: