use of com.google.common.collect.MapMaker in project DirectMemory by raffaeleguidi.
the class PreliminarBenchmarks method pumpWithOneAllocation.
private void pumpWithOneAllocation(int ops, byte[] payload) {
ConcurrentMap<String, ByteBuffer> test = new MapMaker().concurrencyLevel(4).maximumSize(ops).expireAfterWrite(10, TimeUnit.MINUTES).makeMap();
logger.info(Ram.inMb(ops * payload.length) + " in " + ops + " slices to store");
ByteBuffer bulk = ByteBuffer.allocateDirect(ops * payload.length);
double started = System.currentTimeMillis();
for (int i = 0; i < ops; i++) {
bulk.position(i * payload.length);
final ByteBuffer buf = bulk.duplicate();
buf.put(payload);
test.put("test-" + i, buf);
}
double finished = System.currentTimeMillis();
logger.info("done in " + (finished - started) / 1000 + " seconds");
for (ByteBuffer buf : test.values()) {
buf.clear();
}
}
use of com.google.common.collect.MapMaker in project pinpoint by naver.
the class Maps method newWeakConcurrentMap.
public static <K, V> ConcurrentMap<K, V> newWeakConcurrentMap(int initialCapacity) {
final MapMaker weakMapMaker = createWeakMapMaker();
weakMapMaker.initialCapacity(initialCapacity);
return weakMapMaker.makeMap();
}
Aggregations