privatevoid doTestManagerBaseGenerateSessionId(int threadCount, int iterCount) throws Exception {
// Create a default session manager
StandardManager mgr = new StandardManager(); try {
mgr.startInternal();
} catch (LifecycleException e) { // Ignore - this is expected
}
mgr.generateSessionId(); while (mgr.sessionCreationTiming.size() <
ManagerBase.TIMING_STATS_CACHE_SIZE) {
mgr.sessionCreationTiming.add(null);
} while (mgr.sessionExpirationTiming.size() <
ManagerBase.TIMING_STATS_CACHE_SIZE) {
mgr.sessionExpirationTiming.add(null);
}
Thread[] threads = newThread[threadCount];
for (int i = 0; i < threadCount; i++) {
threads[i] = newThread( new TestThreadGenerateSessionId(mgr, iterCount));
}
long start = System.currentTimeMillis();
for (int i = 0; i < threadCount; i++) {
threads[i].start();
} for (int i = 0; i < threadCount; i++) { try {
threads[i].join();
} catch (InterruptedException e) {
e.printStackTrace(); Assert.fail(e.getMessage());
}
} long end = System.currentTimeMillis();
StringBuilder result = new StringBuilder();
result.append("Threads: ");
result.append(threadCount);
result.append(", Time(ms): ");
result.append(end-start);
System.out.println(result.toString());
}
privatevoid doTestManagerBaseCreateSession(int threadCount, int iterCount) throws LifecycleException {
// Create a default session manager
StandardManager mgr = new StandardManager();
mgr.setPathname(null);
Host host = new StandardHost();
host.setName("unittest");
Context context = new StandardContext();
context.setPath("");
context.setParent(host);
mgr.setContext(context);
mgr.start();
mgr.generateSessionId(); while (mgr.sessionCreationTiming.size() <
ManagerBase.TIMING_STATS_CACHE_SIZE) {
mgr.sessionCreationTiming.add(null);
} while (mgr.sessionExpirationTiming.size() <
ManagerBase.TIMING_STATS_CACHE_SIZE) {
mgr.sessionExpirationTiming.add(null);
}
Thread[] threads = newThread[threadCount];
for (int i = 0; i < threadCount; i++) {
threads[i] = newThread( new TestThreadCreateSession(mgr, iterCount));
}
long start = System.currentTimeMillis();
for (int i = 0; i < threadCount; i++) {
threads[i].start();
} for (int i = 0; i < threadCount; i++) { try {
threads[i].join();
} catch (InterruptedException e) {
e.printStackTrace(); Assert.fail(e.getMessage());
}
} long end = System.currentTimeMillis();
StringBuilder result = new StringBuilder();
result.append("Threads: ");
result.append(threadCount);
result.append(", Time(ms): ");
result.append(end-start);
System.out.println(result.toString());
}
privatevoid doTestSecureRandomVsDevURandomInner(int threadCount, int iterCount, boolean useSecureRandom) throws Exception {
Thread[] threads = newThread[threadCount];
for (int i = 0; i < threadCount; i++) { if (useSecureRandom) {
threads[i] = newThread(new TestThreadSecureRandom(iterCount));
} else {
threads[i] = newThread(new TestThreadDevUrandom(iterCount));
}
}
long start = System.currentTimeMillis();
for (int i = 0; i < threadCount; i++) {
threads[i].start();
} for (int i = 0; i < threadCount; i++) { try {
threads[i].join();
} catch (InterruptedException e) {
e.printStackTrace(); Assert.fail(e.getMessage());
}
} long end = System.currentTimeMillis();
StringBuilder result = new StringBuilder(); if (useSecureRandom) {
result.append("SecureRandom ");
} else {
result.append("/dev/urandom ");
}
result.append("Threads: ");
result.append(threadCount);
result.append(", Time(ms): ");
result.append(end-start);
System.out.println(result.toString());
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.