[dna-commits] DNA SVN: r292 - trunk/dna-common/src/test/java/org/jboss/dna/common/stats.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Mon Jun 16 17:27:24 EDT 2008


Author: rhauch
Date: 2008-06-16 17:27:24 -0400 (Mon, 16 Jun 2008)
New Revision: 292

Modified:
   trunk/dna-common/src/test/java/org/jboss/dna/common/stats/StopwatchTest.java
Log:
DNA-135: Time-based stopwatch tests sometimes fail on slow machines
http://jira.jboss.org/jira/browse/DNA-135

I suspect the most likely cause is the call to "Thread.sleep".  These total number of milliseconds was pretty small and probably too close to the precision of the system clock, so I increased the value by an order of magnitude.  Hopefully this will improve the likelihood of the tests passing.  If not, we'll need to test these using a different technique, or ignore these tests.  Greg, please comment with your results (and please reopen if the change is not successful).

Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/stats/StopwatchTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/stats/StopwatchTest.java	2008-06-16 20:31:26 UTC (rev 291)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/stats/StopwatchTest.java	2008-06-16 21:27:24 UTC (rev 292)
@@ -112,40 +112,40 @@
     public void shouldReportTotalTime() {
         for (int i = 0; i != 4; ++i) {
             stopwatch.start();
-            pause(10);
+            pause(100);
             stopwatch.stop();
         }
-        assertThat((double)stopwatch.getTotalDuration().getDuration(TimeUnit.MILLISECONDS), is(closeTo(40, 10)));
+        assertThat((double)stopwatch.getTotalDuration().getDuration(TimeUnit.MILLISECONDS), is(closeTo(400, 100)));
     }
 
     @Test
     public void shouldReportAverageTime() {
         for (int i = 0; i != 4; ++i) {
             stopwatch.start();
-            pause(10);
+            pause(100);
             stopwatch.stop();
         }
-        assertThat((double)stopwatch.getAverageDuration().getDuration(TimeUnit.MILLISECONDS), is(closeTo(10, 5)));
+        assertThat((double)stopwatch.getAverageDuration().getDuration(TimeUnit.MILLISECONDS), is(closeTo(100, 25)));
     }
 
     @Test
     public void shouldReportMinimumTime() {
         for (int i = 0; i != 3; ++i) {
             stopwatch.start();
-            pause(10 * (i + 1));
+            pause(50 * (i + 1));
             stopwatch.stop();
         }
-        assertThat((double)stopwatch.getMinimumDuration().getDuration(TimeUnit.MILLISECONDS), is(closeTo(10, 5)));
+        assertThat((double)stopwatch.getMinimumDuration().getDuration(TimeUnit.MILLISECONDS), is(closeTo(50, 20)));
     }
 
     @Test
     public void shouldReportMaximumTime() {
         for (int i = 0; i != 3; ++i) {
             stopwatch.start();
-            pause(10 * (i + 1));
+            pause(50 * (i + 1));
             stopwatch.stop();
         }
-        assertThat((double)stopwatch.getMaximumDuration().getDuration(TimeUnit.MILLISECONDS), is(closeTo(30, 5)));
+        assertThat((double)stopwatch.getMaximumDuration().getDuration(TimeUnit.MILLISECONDS), is(closeTo(150, 25)));
     }
 
     @Test




More information about the dna-commits mailing list