Author: markt
Date: Thu Feb 5 14:32:03 2015
New Revision: 1657584
URL: http://svn.apache.org/r1657584
Log:
Refactor Mapper performance tests to a separate class so they can be more
easily excluded.
Added:
tomcat/trunk/test/org/apache/catalina/mapper/TestMapperPerformance.java
(with props)
Modified:
tomcat/trunk/test/org/apache/catalina/mapper/TestMapper.java
Modified: tomcat/trunk/test/org/apache/catalina/mapper/TestMapper.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/mapper/TestMapper.java?rev=1657584&r1=1657583&r2=1657584&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/mapper/TestMapper.java (original)
+++ tomcat/trunk/test/org/apache/catalina/mapper/TestMapper.java Thu Feb 5
14:32:03 2015
@@ -41,7 +41,7 @@ import org.apache.tomcat.util.buf.Messag
public class TestMapper extends LoggingBaseTest {
- private Mapper mapper;
+ protected Mapper mapper;
private HashMap<String, Host> hostMap = new HashMap<>();
@@ -538,38 +538,4 @@ public class TestMapper extends LoggingB
assertEquals("/foo/bar/bla", mappingData.contextPath.toString());
}
}
-
- @Test
- public void testPerformance() throws Exception {
- // Takes ~1s on markt's laptop. If this takes more than 5s something
- // probably needs looking at. If this fails repeatedly then we may need
- // to increase this limit.
- final long maxTime = 5000;
- long time = testPerformanceImpl();
- if (time >= maxTime) {
- // Rerun to reject occasional failures, e.g. because of gc
- log.warn("testPerformance() test completed in " + time + " ms");
- time = testPerformanceImpl();
- log.warn("testPerformance() test rerun completed in " + time + "
ms");
- }
- assertTrue(String.valueOf(time), time < maxTime);
- }
-
- private long testPerformanceImpl() throws Exception {
- MappingData mappingData = new MappingData();
- MessageBytes host = MessageBytes.newInstance();
- host.setString("iowejoiejfoiew");
- MessageBytes uri = MessageBytes.newInstance();
- uri.setString("/foo/bar/blah/bobou/foo");
- uri.toChars();
- uri.getCharChunk().setLimit(-1);
-
- long start = System.currentTimeMillis();
- for (int i = 0; i < 1000000; i++) {
- mappingData.recycle();
- mapper.map(host, uri, null, mappingData);
- }
- long time = System.currentTimeMillis() - start;
- return time;
- }
}
Added: tomcat/trunk/test/org/apache/catalina/mapper/TestMapperPerformance.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/mapper/TestMapperPerformance.java?rev=1657584&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/mapper/TestMapperPerformance.java
(added)
+++ tomcat/trunk/test/org/apache/catalina/mapper/TestMapperPerformance.java Thu
Feb 5 14:32:03 2015
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.mapper;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import org.apache.tomcat.util.buf.MessageBytes;
+
+public class TestMapperPerformance extends TestMapper {
+
+ @Test
+ public void testPerformance() throws Exception {
+ // Takes ~1s on markt's laptop. If this takes more than 5s something
+ // probably needs looking at. If this fails repeatedly then we may need
+ // to increase this limit.
+ final long maxTime = 5000;
+ long time = testPerformanceImpl();
+ if (time >= maxTime) {
+ // Rerun to reject occasional failures, e.g. because of gc
+ log.warn("testPerformance() test completed in " + time + " ms");
+ time = testPerformanceImpl();
+ log.warn("testPerformance() test rerun completed in " + time + "
ms");
+ }
+ assertTrue(String.valueOf(time), time < maxTime);
+ }
+
+ private long testPerformanceImpl() throws Exception {
+ MappingData mappingData = new MappingData();
+ MessageBytes host = MessageBytes.newInstance();
+ host.setString("iowejoiejfoiew");
+ MessageBytes uri = MessageBytes.newInstance();
+ uri.setString("/foo/bar/blah/bobou/foo");
+ uri.toChars();
+ uri.getCharChunk().setLimit(-1);
+
+ long start = System.currentTimeMillis();
+ for (int i = 0; i < 1000000; i++) {
+ mappingData.recycle();
+ mapper.map(host, uri, null, mappingData);
+ }
+ long time = System.currentTimeMillis() - start;
+ return time;
+ }
+
+}
Propchange:
tomcat/trunk/test/org/apache/catalina/mapper/TestMapperPerformance.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]