198 |
|
} |
199 |
|
|
200 |
|
protected void runTestProfiled() throws Throwable { |
201 |
< |
// Warmup run, notably to trigger all needed classloading. |
202 |
< |
super.runTest(); |
203 |
< |
long t0 = System.nanoTime(); |
204 |
< |
try { |
201 |
> |
for (int i = 0; i < 2; i++) { |
202 |
> |
long startTime = System.nanoTime(); |
203 |
|
super.runTest(); |
204 |
< |
} finally { |
205 |
< |
long elapsedMillis = millisElapsedSince(t0); |
206 |
< |
if (elapsedMillis >= profileThreshold) |
204 |
> |
long elapsedMillis = millisElapsedSince(startTime); |
205 |
> |
if (elapsedMillis < profileThreshold) |
206 |
> |
break; |
207 |
> |
// Never report first run of any test; treat it as a |
208 |
> |
// warmup run, notably to trigger all needed classloading, |
209 |
> |
if (i > 0) |
210 |
|
System.out.printf("%n%s: %d%n", toString(), elapsedMillis); |
211 |
|
} |
212 |
|
} |
1224 |
|
public static final String TEST_STRING = "a test string"; |
1225 |
|
|
1226 |
|
public static class StringTask implements Callable<String> { |
1227 |
< |
public String call() { return TEST_STRING; } |
1227 |
> |
final String value; |
1228 |
> |
public StringTask() { this(TEST_STRING); } |
1229 |
> |
public StringTask(String value) { this.value = value; } |
1230 |
> |
public String call() { return value; } |
1231 |
|
} |
1232 |
|
|
1233 |
|
public Callable<String> latchAwaitingStringTask(final CountDownLatch latch) { |