[cvs] / jsr166 / src / test / tck / SystemTest.java Repository:
ViewVC logotype

Diff of /jsr166/src/test/tck/SystemTest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5, Sat Dec 27 19:26:44 2003 UTC revision 1.7, Mon Nov 2 20:28:32 2009 UTC
# Line 18  Line 18 
18      }      }
19    
20      /**      /**
21         * Worst case rounding for millisecs; set for 60 cycle millis clock.
22         * This value might need to be changed os JVMs with coarser
23         *  System.currentTimeMillis clocks.
24         */
25        static final long MILLIS_ROUND = 17;
26    
27        /**
28       * Nanos between readings of millis is no longer than millis (plus       * Nanos between readings of millis is no longer than millis (plus
29       * one milli to allow for rounding).       * possible rounding).
30       * This shows only that nano timing not (much) worse than milli.       * This shows only that nano timing not (much) worse than milli.
31       */       */
32      public void testNanoTime1() {      public void testNanoTime1() {
# Line 33  Line 40 
40              long m2 = System.currentTimeMillis();              long m2 = System.currentTimeMillis();
41              long millis = m2 - m1;              long millis = m2 - m1;
42              long nanos = n2 - n1;              long nanos = n2 - n1;
   
43              assertTrue(nanos >= 0);              assertTrue(nanos >= 0);
44              assertTrue(nanos < (millis+1) * 1000000);              long nanosAsMillis = nanos / 1000000;
45                assertTrue(nanosAsMillis <= millis + MILLIS_ROUND);
46          }          }
47          catch(InterruptedException ie) {          catch(InterruptedException ie) {
48              unexpectedException();              unexpectedException();
# Line 43  Line 50 
50      }      }
51    
52      /**      /**
53       * Millis between readings of nanos is no longer than nanos       * Millis between readings of nanos is less than nanos, adjusting
54         * for rounding.
55       * This shows only that nano timing not (much) worse than milli.       * This shows only that nano timing not (much) worse than milli.
56       */       */
57      public void testNanoTime2() {      public void testNanoTime2() {
# Line 59  Line 67 
67              long nanos = n2 - n1;              long nanos = n2 - n1;
68    
69              assertTrue(nanos >= 0);              assertTrue(nanos >= 0);
70              assertTrue(millis * 1000000 <= nanos);              long nanosAsMillis = nanos / 1000000;
71                assertTrue(millis <= nanosAsMillis + MILLIS_ROUND);
72          }          }
73          catch(InterruptedException ie) {          catch(InterruptedException ie) {
74              unexpectedException();              unexpectedException();
# Line 67  Line 76 
76      }      }
77    
78  }  }
   

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.7

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8