I'm committing the attached patch to add System.nanoTime()
from the generics branch.

Changelog:

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.

-- 
Andrew :-)

Please avoid sending me Microsoft Office (e.g. Word, PowerPoint) attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html

If you use Microsoft Office, support movement towards the end of vendor lock-in:
http://opendocumentfellowship.org/petition/

"Value your freedom, or you will lose it, teaches history. 
`Don't bother us with politics' respond those who don't want to learn." 
-- Richard Stallman

Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html
public class gcj extends Freedom implements Java { ... }
Index: java/lang/System.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/System.java,v
retrieving revision 1.57
diff -u -3 -p -u -r1.57 System.java
--- java/lang/System.java       12 May 2006 15:54:38 -0000      1.57
+++ java/lang/System.java       4 Jun 2006 18:12:25 -0000
@@ -222,6 +222,36 @@ public final class System
     return VMSystem.currentTimeMillis();
   }
 
+  /** 
+   * <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> ...

Attachment: signature.asc
Description: Digital signature

Reply via email to