# HG changeset patch # User dfuchs # Date 1510918946 0 # Node ID ac0c821cc75cb54a6896957982105d6221fe01cb # Parent 282ec90391875c22414dd22c3b1bd5f5ddb79caf http-client-branch: adding time information to BufferingSubscriberTest.java diff -r 282ec9039187 -r ac0c821cc75c test/jdk/java/net/httpclient/BufferingSubscriberTest.java --- a/test/jdk/java/net/httpclient/BufferingSubscriberTest.java Fri Nov 17 14:22:07 2017 +0300 +++ b/test/jdk/java/net/httpclient/BufferingSubscriberTest.java Fri Nov 17 11:42:26 2017 +0000 @@ -56,7 +56,18 @@ public class BufferingSubscriberTest { static final Random random = RandomFactory.getRandom(); - + static final long start = System.nanoTime(); + static final String START = "start"; + static final String END = "end "; + static long elapsed() { return (System.nanoTime() - start)/1000_000;} + static void printStamp(String what, String fmt, Object... args) { + long elapsed = elapsed(); + long sec = elapsed/1000; + long ms = elapsed % 1000; + String time = sec > 0 ? sec + "sec " : ""; + time = time + ms + "ms"; + out.println(what + "\t ["+time+"]\t "+ String.format(fmt,args)); + } @DataProvider(name = "negatives") public Object[][] negatives() { return new Object[][] { { 0 }, { -1 }, { -1000 } }; @@ -64,14 +75,24 @@ @Test(dataProvider = "negatives", expectedExceptions = IllegalArgumentException.class) public void subscriberThrowsIAE(int bufferSize) { - BodySubscriber bp = BodySubscriber.asByteArray(); - BodySubscriber.buffering(bp, bufferSize); + printStamp(START, "subscriberThrowsIAE(%d)", bufferSize); + try { + BodySubscriber bp = BodySubscriber.asByteArray(); + BodySubscriber.buffering(bp, bufferSize); + } finally { + printStamp(END, "subscriberThrowsIAE(%d)", bufferSize); + } } @Test(dataProvider = "negatives", expectedExceptions = IllegalArgumentException.class) public void handlerThrowsIAE(int bufferSize) { - BodyHandler bp = BodyHandler.asByteArray(); - BodyHandler.buffering(bp, bufferSize); + printStamp(START, "handlerThrowsIAE(%d)", bufferSize); + try { + BodyHandler bp = BodyHandler.asByteArray(); + BodyHandler.buffering(bp, bufferSize); + } finally { + printStamp(END, "handlerThrowsIAE(%d)", bufferSize); + } } // --- @@ -120,21 +141,24 @@ long requestAmount) { ExecutorService executor = Executors.newFixedThreadPool(1); try { - out.printf("Iterations %d\n", iterations); for (int i=0; i> publisher = - new SubmissionPublisher<>(executor, 1); - CompletableFuture cf = sink(publisher, - delayMillis, - numBuffers * bufferSize, - requestAmount, - maxBufferSize, - minBufferSize); - source(publisher, numBuffers, bufferSize); - publisher.close(); - cf.join(); + printStamp(START, "Iteration %d", i); + try { + SubmissionPublisher> publisher = + new SubmissionPublisher<>(executor, 1); + CompletableFuture cf = sink(publisher, + delayMillis, + numBuffers * bufferSize, + requestAmount, + maxBufferSize, + minBufferSize); + source(publisher, numBuffers, bufferSize); + publisher.close(); + cf.join(); + } finally { + printStamp(END, "Iteration %d\n", i); + } } out.println("OK"); } finally { @@ -299,7 +323,7 @@ static void source(SubmissionPublisher> publisher, int numBuffers, int bufferSize) { - out.printf("Publishing %d buffers of size %d each\n", numBuffers, bufferSize); + printStamp("source","Publishing %d buffers of size %d each", numBuffers, bufferSize); int index = 0; for (int i=0; i