You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2015/02/05 09:18:50 UTC
svn commit: r1657492 -
/tomcat/trunk/test/org/apache/catalina/connector/TestResponsePerformance.java
Author: markt
Date: Thu Feb 5 08:18:50 2015
New Revision: 1657492
URL: http://svn.apache.org/r1657492
Log:
Re-work test to use a warm-up followed by a "best of 5" approach to try and avoid false failures with the CI system. (Running on my laptop, homebrew is ~2x as fast).
Modified:
tomcat/trunk/test/org/apache/catalina/connector/TestResponsePerformance.java
Modified: tomcat/trunk/test/org/apache/catalina/connector/TestResponsePerformance.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/connector/TestResponsePerformance.java?rev=1657492&r1=1657491&r2=1657492&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/connector/TestResponsePerformance.java (original)
+++ tomcat/trunk/test/org/apache/catalina/connector/TestResponsePerformance.java Thu Feb 5 08:18:50 2015
@@ -22,28 +22,53 @@ import static org.junit.Assert.assertTru
import org.junit.Test;
public class TestResponsePerformance {
+
+ private final int ITERATIONS = 100000;
+
@Test
public void testToAbsolutePerformance() throws Exception {
Request req = new TesterRequest();
Response resp = new Response();
resp.setRequest(req);
+ // Warm up
+ doHomebrew(resp);
+ doUri();
+
+ final int bestOf = 5;
+ final int winTarget = (bestOf + 1) / 2;
+ int homebrewWin = 0;
+ int count = 0;
+
+ while (count < bestOf && homebrewWin < winTarget) {
+ long homebrew = doHomebrew(resp);
+ long uri = doUri();
+ System.out.println("Current 'home-brew': " + homebrew + "ms, Using URI: " + uri + "ms");
+ if (homebrew < uri) {
+ homebrewWin++;
+ }
+ count++;
+ }
+ assertTrue(homebrewWin == winTarget);
+ }
+
+
+ private long doHomebrew(Response resp) {
long start = System.currentTimeMillis();
- for (int i = 0; i < 100000; i++) {
+ for (int i = 0; i < ITERATIONS; i++) {
resp.toAbsolute("bar.html");
}
- long homebrew = System.currentTimeMillis() - start;
+ return System.currentTimeMillis() - start;
+ }
- start = System.currentTimeMillis();
- for (int i = 0; i < 100000; i++) {
+
+ private long doUri() {
+ long start = System.currentTimeMillis();
+ for (int i = 0; i < ITERATIONS; i++) {
URI base = URI.create(
"http://localhost:8080/level1/level2/foo.html");
base.resolve(URI.create("bar.html")).toASCIIString();
}
- long uri = System.currentTimeMillis() - start;
-
- System.out.println("Current 'home-brew': " + homebrew +
- "ms, Using URI: " + uri + "ms");
- assertTrue(homebrew < uri);
+ return System.currentTimeMillis() - start;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org