0,0 → 1,87 |
package ak.backpath.test; |
|
import java.util.Map; |
import javax.servlet.http.HttpServletRequest; |
import ak.backpath.BackPath; |
|
public class BackPathTest |
{ |
|
public static void main(String[] args) |
throws Exception |
{ |
int n = 50000; |
int m = 1; |
|
TestThread[] threads = new TestThread[m]; |
|
for(int i = 0; i < threads.length; i++) { |
threads[i] = new TestThread(n); |
} |
|
long t1 = System.currentTimeMillis(); |
for(int i = 0; i < threads.length; i++) { |
threads[i].start(); |
} |
for(int i = 0; i < threads.length; i++) { |
threads[i].join(); |
} |
long t2 = System.currentTimeMillis(); |
|
System.out.println(m + " threads * " + n + " iterations = " + (t2-t1) + " ms"); |
System.out.println((((long)m*n*1000)/(t2-t1)) + " requests/s"); |
} |
|
private static class TestThread extends Thread |
{ |
private int n; |
|
public TestThread(int n) |
{ |
this.n = n; |
} |
|
public void run() { |
try { |
Map params = new java.util.HashMap(); |
DummyRequest request; |
BackPath backPath; |
String pathString; |
|
// index |
params.clear(); |
request = new DummyRequest("http://localhost/testapp/index.do", params); |
backPath = BackPath.findBackPath(request); |
pathString = backPath.getForwardParams(); |
backPath.getBackwardUrl(); |
|
// list |
params.clear(); |
params.put("backpath", new String[] { pathString }); |
params.put("show", new String[] { "true" }); |
request = new DummyRequest("http://localhost/testapp/some/list.do?show=true", params); |
backPath = BackPath.findBackPath(request); |
pathString = backPath.getForwardParams(); |
backPath.getBackwardUrl(); |
|
// details |
params.clear(); |
params.put("backpath", new String[] { pathString }); |
params.put("id", new String[] { "123" }); |
params.put("show", new String[] { "true" }); |
request = new DummyRequest("http://localhost/testapp/some/details.do?id=123&show=true", params); |
|
for(int i = 0; i < n; i++) { |
request.clearAttributes(); |
backPath = BackPath.findBackPath(request); |
backPath.getCurrentParams(); |
backPath.getForwardParams(); |
backPath.getBackwardUrl(); |
} |
} |
catch(Exception ex) { |
ex.printStackTrace(); |
} |
} |
} |
} |