Here's an update diff for the elapsed time check.
   - added current CR# to @bug tag
   - moved capture of start time to after creation of the latches
      so only the schedule*() and the await() calls are included
      in the elapsed time check.

jdk/test/java/util/Timer/Args.java

 /*
  * @test
- * @bug 6571655 6571881 6574585 6571297
+ * @bug 6571655 6571881 6574585 6571297 6731620
  * @summary Test various args to task scheduling methods
  */

@@ -92,19 +92,21 @@
                new F(){void f(){ t.scheduleAtFixedRate(x, (Date)null, 42); }}
                );

-        final long start = System.currentTimeMillis();
-        final Date past = new Date(start - 10500);
         final CountDownLatch y1 = new CountDownLatch(1);
         final CountDownLatch y2 = new CountDownLatch(1);
         final CountDownLatch y3 = new CountDownLatch(11);
+        final long start = System.currentTimeMillis();
+        final Date past = new Date(start - 10500);
+    final long elapsed;
         schedule(           t, counter(y1), past);
         schedule(           t, counter(y2), past, 1000);
         scheduleAtFixedRate(t, counter(y3), past, 1000);
         y3.await();
         y1.await();
         y2.await();
-        System.out.printf("elapsed=%d%n", System.currentTimeMillis() - start);
-        check(System.currentTimeMillis() - start < 500);
+    elapsed = System.currentTimeMillis() - start;
+        System.out.printf("elapsed=%d%n", elapsed);
+        check(elapsed < 500);

         t.cancel();




On 11/ 4/11 09:36 AM, Gary Adams wrote:
 I've started to look at timing related bugs that have been open
for a while, but have not had sufficient priority to make it to the
top of the list of bugs to be fixed. Thought I'd start with some
low hanging fruit with simple bug fixes.

6731620: TEST_BUG: java/util/Timer/Args.java is too optimistic about the execution time of System.out.printf

This seems like a simply problem to avoid two calls to get the current time
and to eliminated the time to process the print statement
from the evaluation of the test elapsed time.

Replacing this sequence ;

        System.out.printf("elapsed=%d%n", System.currentTimeMillis() - start);
        check(System.currentTimeMillis() - start < 500);

with

        elapsed = System.currentTimeMillis() - start;
        System.out.printf("elapsed=%d%n", elapsed);
        check(elapsed < 500);

I plan to test the fix on a 300MHz linux/arm device.
I'll provide a proper webrev as soon as I have author rights
confirmed. I'm looking for reviewer and a committer,
once I get the fix tested locally.

Thanks
  Gary Adams


Reply via email to