final ConcurrentPluggableCache<Long, byte[]> cache = new ConcurrentPluggableCache<Long, byte[]>(capacity, ConcurrentCollectionProvider.<ICacheEntry<Long, byte[]>> createConcurrentMapLong(capacity));
cache.setReplacementPolicy(ReplacementPolicySelector.<Long, byte[]> provide(capacity, algo));
final int total = round * threads;
final double percent = scanPercentage / 100d;
StopWatch watchdog = new StopWatch("nthreads: " + threads + ", capacity: " + capacity
+ ", invocations: " + total + ", scanPercentage: " + percent + ", scanLength: "
+ scanLength + ", pageSize: " + pageSize);
final FixedSegments pager = makeTempSegments(pageSize);
final ExecutorService exec = Executors.newFixedThreadPool(threads);
try {
for(int i = 0; i < threads; i++) {
final int threadId = i;
exec.submit(new Runnable() {
public void run() {
try {
if(lock == null) {
runBenchmarkWithZipfDistributionSync(pager, cache, capacity, round, percent, scanLength, dist[threadId]);
} else {
runBenchmarkWithZipfDistributionLock(lock, pager, cache, capacity, round, percent, scanLength, dist[threadId]);
}
} catch (Throwable e) {
e.printStackTrace();
}
}
});
}
} finally {
exec.shutdown();
try {
exec.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
} catch (InterruptedException e) {
;
}
}
long miss = cache.getCacheMiss();
long hit = total - miss;
double hitRatio = ((double) hit) / total;
double missRatio = ((double) miss) / total;
System.err.println("["
+ algo
+ " - "
+ filename
+ "] synchronization: "
+ (lock == null ? "sync" : ((lock instanceof NoopLock) ? "non-blocking"
: "spinlock")) + ", read: " + total + ", miss: " + miss + ", hit ratio: "
+ hitRatio + ", miss ratio: " + missRatio);
System.err.println(watchdog.toString());
System.err.flush();
pager.close();
}