use of org.eclipse.collections.impl.map.mutable.ConcurrentHashMap in project eclipse-collections by eclipse.
the class SerialParallelLazyPerformanceTest method forEach.
private void forEach(FastList<Integer> collection) {
MutableList<Runnable> runnables = FastList.newList();
runnables.add(() -> this.basicSerialForEachPerformance(collection, SERIAL_RUN_COUNT));
int cores = Runtime.getRuntime().availableProcessors();
ExecutorService service = Executors.newFixedThreadPool(cores);
runnables.add(() -> {
MutableMap<Integer, Boolean> map = new ConcurrentHashMap<>();
this.basicParallelLazyForEachPerformance(collection, "Lambda", item -> map.put(item, Boolean.TRUE), PARALLEL_RUN_COUNT, cores, service);
});
runnables.add(() -> {
MutableMap<Integer, Boolean> map = new ConcurrentHashMap<>();
this.basicParallelLazyForEachPerformance(collection, "Procedure", (Procedure<Integer>) each -> map.put(each, Boolean.TRUE), PARALLEL_RUN_COUNT, cores, service);
});
runnables.add(() -> {
MutableMap<Integer, Boolean> map = new ConcurrentHashMap<>();
this.basicJava8ParallelLazyForEachPerformance(collection, "Lambda", item -> map.put(item, Boolean.TRUE), PARALLEL_RUN_COUNT);
});
List<Integer> arrayList = new ArrayList<>(collection);
runnables.add(() -> {
MutableMap<Integer, Boolean> map = new ConcurrentHashMap<>();
this.basicJava8ParallelLazyForEachPerformance(arrayList, "Lambda", item -> map.put(item, Boolean.TRUE), PARALLEL_RUN_COUNT);
});
runnables.add(() -> {
MutableMap<Integer, Boolean> map = new ConcurrentHashMap<>();
this.basicJava8ParallelLazyForEachPerformance(arrayList, "Consumer", each -> map.put(each, Boolean.TRUE), PARALLEL_RUN_COUNT);
});
this.shuffleAndRun(runnables);
service.shutdown();
try {
service.awaitTermination(1, TimeUnit.MINUTES);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
use of org.eclipse.collections.impl.map.mutable.ConcurrentHashMap in project eclipse-collections by eclipse.
the class ConcurrentHashMapTest method newWith.
@Override
public <T> MutableMap<Object, T> newWith(T... elements) {
Random random = new Random(CURRENT_TIME_MILLIS);
MutableMap<Object, T> result = new ConcurrentHashMap<>();
for (T each : elements) {
assertNull(result.put(random.nextDouble(), each));
}
return result;
}
Aggregations