ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/SystemTest.java
(Generate patch)

Comparing jsr166/src/test/tck/SystemTest.java (file contents):
Revision 1.7 by jsr166, Mon Nov 2 20:28:32 2009 UTC vs.
Revision 1.11 by jsr166, Tue Mar 15 19:47:07 2011 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   * Other contributors include Andrew Wright, Jeffrey Hayes,
6   * Pat Fisher, Mike Judd.
7   */
# Line 19 | Line 19 | public class SystemTest extends JSR166Te
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.
22 >     * This value might need to be changed on JVMs with coarser
23 >     * System.currentTimeMillis clocks.
24       */
25      static final long MILLIS_ROUND = 17;
26  
# Line 29 | Line 29 | public class SystemTest extends JSR166Te
29       * possible rounding).
30       * This shows only that nano timing not (much) worse than milli.
31       */
32 <    public void testNanoTime1() {
33 <        try {
34 <            long m1 = System.currentTimeMillis();
35 <            Thread.sleep(1);
36 <            long n1 = System.nanoTime();
37 <            Thread.sleep(SHORT_DELAY_MS);
38 <            long n2 = System.nanoTime();
39 <            Thread.sleep(1);
40 <            long m2 = System.currentTimeMillis();
41 <            long millis = m2 - m1;
42 <            long nanos = n2 - n1;
43 <            assertTrue(nanos >= 0);
44 <            long nanosAsMillis = nanos / 1000000;
45 <            assertTrue(nanosAsMillis <= millis + MILLIS_ROUND);
46 <        }
47 <        catch(InterruptedException ie) {
48 <            unexpectedException();
49 <        }
32 >    public void testNanoTime1() throws InterruptedException {
33 >        long m1 = System.currentTimeMillis();
34 >        Thread.sleep(1);
35 >        long n1 = System.nanoTime();
36 >        Thread.sleep(SHORT_DELAY_MS);
37 >        long n2 = System.nanoTime();
38 >        Thread.sleep(1);
39 >        long m2 = System.currentTimeMillis();
40 >        long millis = m2 - m1;
41 >        long nanos = n2 - n1;
42 >        assertTrue(nanos >= 0);
43 >        long nanosAsMillis = nanos / 1000000;
44 >        assertTrue(nanosAsMillis <= millis + MILLIS_ROUND);
45      }
46  
47      /**
# Line 54 | Line 49 | public class SystemTest extends JSR166Te
49       * for rounding.
50       * This shows only that nano timing not (much) worse than milli.
51       */
52 <    public void testNanoTime2() {
53 <        try {
54 <            long n1 = System.nanoTime();
55 <            Thread.sleep(1);
56 <            long m1 = System.currentTimeMillis();
57 <            Thread.sleep(SHORT_DELAY_MS);
58 <            long m2 = System.currentTimeMillis();
59 <            Thread.sleep(1);
60 <            long n2 = System.nanoTime();
61 <            long millis = m2 - m1;
62 <            long nanos = n2 - n1;
63 <
64 <            assertTrue(nanos >= 0);
65 <            long nanosAsMillis = nanos / 1000000;
71 <            assertTrue(millis <= nanosAsMillis + MILLIS_ROUND);
72 <        }
73 <        catch(InterruptedException ie) {
74 <            unexpectedException();
75 <        }
52 >    public void testNanoTime2() throws InterruptedException {
53 >        long n1 = System.nanoTime();
54 >        Thread.sleep(1);
55 >        long m1 = System.currentTimeMillis();
56 >        Thread.sleep(SHORT_DELAY_MS);
57 >        long m2 = System.currentTimeMillis();
58 >        Thread.sleep(1);
59 >        long n2 = System.nanoTime();
60 >        long millis = m2 - m1;
61 >        long nanos = n2 - n1;
62 >
63 >        assertTrue(nanos >= 0);
64 >        long nanosAsMillis = nanos / 1000000;
65 >        assertTrue(millis <= nanosAsMillis + MILLIS_ROUND);
66      }
67  
68   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines