ASF Bugzilla – Attachment 25317 Details for
Bug 48922
org.apache.catalina.connector.Request clone static SimpleDateFormat
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Test performance creation of the Request() object
bug48922_TestCase.patch (text/plain), 3.53 KB, created by
Daniel Lemon
on 2010-04-17 11:40:00 UTC
(
hide
)
Description:
Test performance creation of the Request() object
Filename:
MIME Type:
Creator:
Daniel Lemon
Created:
2010-04-17 11:40:00 UTC
Size:
3.53 KB
patch
obsolete
>Index: test/org/apache/catalina/connector/TestBenchmarkDate.java >=================================================================== >--- test/org/apache/catalina/connector/TestBenchmarkDate.java (revision 0) >+++ test/org/apache/catalina/connector/TestBenchmarkDate.java (revision 0) >@@ -0,0 +1,90 @@ >+/* >+ * 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.connector; >+ >+import junit.framework.TestCase; >+ >+/** >+ * Some testing performed at the OpenSource Jumpstart event at IBM >+ */ >+public class TestBenchmarkDate extends TestCase { >+ >+ public void testBug48922() throws Exception { >+ // Is it better to use a sync or a thread local here? >+ BenchmarkTest benchmark = new BenchmarkTest(); >+ Runnable[] tests = new Runnable[] { >+ new TestBenchmarkInitTime() }; >+ benchmark.doTest(5, tests); >+ } >+ >+ private static class TestBenchmarkInitTime implements Runnable { >+ >+ @Override >+ public void run() { >+ // TODO Auto-generated method stub >+ new Request(); >+ } >+ } >+ >+ private static class BenchmarkTest { >+ public void doTest(int threadCount, Runnable[] tests) throws Exception { >+ for (int iterations = 100000; iterations < 1000001; iterations += 100000) { >+ for (int i = 0; i < tests.length; i++) { >+ doTestInternal(threadCount, iterations, tests[i]); >+ } >+ } >+ } >+ >+ private void doTestInternal(int threadCount, int iterations, >+ Runnable test) throws Exception { >+ long start = System.currentTimeMillis(); >+ Thread[] threads = new Thread[threadCount]; >+ for (int i = 0; i < threadCount; i++) { >+ threads[i] = new Thread(new TestThread(iterations, test)); >+ } >+ for (int i = 0; i < threadCount; i++) { >+ threads[i].start(); >+ } >+ for (int i = 0; i < threadCount; i++) { >+ threads[i].join(); >+ } >+ long end = System.currentTimeMillis(); >+ >+ System.out.println(test.getClass().getSimpleName() + ": " >+ + threadCount + " threads and " + iterations >+ + " iterations using " + test + " took " + (end - start) >+ + "ms"); >+ } >+ } >+ >+ private static class TestThread implements Runnable { >+ private int count; >+ private Runnable test; >+ >+ public TestThread(int count, Runnable test) { >+ this.count = count; >+ this.test = test; >+ } >+ >+ public void run() { >+ for (int i = 0; i < count; i++) { >+ test.run(); >+ } >+ } >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 48922
: 25317 |
25318