--- old/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java 2014-11-28 21:14:14.492037826 +0400 +++ new/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java 2014-11-28 21:14:14.269326608 +0400 @@ -27,6 +27,7 @@ import java.lang.reflect.Method; import java.util.Collection; import java.util.function.Function; +import jdk.testlibrary.Utils; /** * Lambda forms caching test case class. Contains all necessary test routines to @@ -41,7 +42,8 @@ private final static String INTERNAL_FORM_METHOD_NAME = "internalForm"; private static final double ITERATIONS_TO_CODE_CACHE_SIZE_RATIO = 45 / (128.0 * 1024 * 1024); - + private static final long TIMEOUT = Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT); + /** * Reflection link to {@code j.l.i.MethodHandle.internalForm} method. It is * used to get a lambda form from a method handle. @@ -109,7 +111,10 @@ System.out.printf("Number of iterations is set to %d (%d cases)%n", iterations, iterations * testCaseNum); System.out.flush(); + long maxIterTime = 0; + long startTime = System.currentTimeMillis(); for (long i = 0; i < iterations; i++) { + long startIterTime = System.currentTimeMillis(); System.err.println(String.format("Iteration %d:", i)); for (TestMethods testMethod : testMethods) { LambdaFormTestCase testCase = ctor.apply(testMethod); @@ -126,6 +131,15 @@ } testCounter++; } + long passedTime = System.currentTimeMillis() - startTime; + long iterTime = System.currentTimeMillis() - startIterTime; + maxIterTime = Math.max(maxIterTime, iterTime); + long remainTime = TIMEOUT - passedTime; + if (4 * maxIterTime > remainTime) { + System.err.printf("Stopping iterations because of lack of time.%n" + + "Increase timeout factor for more iterations.%n"); + break; + } } if (!passed) { throw new Error(String.format("%d of %d test cases FAILED! %n"