use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testMappedForEachKeySequentially.
/**
* Mapped forEachKeySequentially traverses the given
* transformations of all keys
*/
public void testMappedForEachKeySequentially() {
LongAdder adder = new LongAdder();
ConcurrentHashMap<Long, Long> m = longMap();
m.forEachKey(Long.MAX_VALUE, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x) -> adder.add(x.longValue()));
assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1) / 2);
}
use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testForEachValueInParallel.
/**
* forEachValueInParallel traverses all values
*/
public void testForEachValueInParallel() {
LongAdder adder = new LongAdder();
ConcurrentHashMap<Long, Long> m = longMap();
m.forEachValue(1L, (Long x) -> adder.add(x.longValue()));
assertEquals(adder.sum(), SIZE * (SIZE - 1));
}
use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testForEachSequentially.
/**
* forEachSequentially traverses all mappings
*/
public void testForEachSequentially() {
LongAdder adder = new LongAdder();
ConcurrentHashMap<Long, Long> m = longMap();
m.forEach(Long.MAX_VALUE, (Long x, Long y) -> adder.add(x.longValue() + y.longValue()));
assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}
use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testForEachKeySequentially.
/**
* forEachKeySequentially traverses all keys
*/
public void testForEachKeySequentially() {
LongAdder adder = new LongAdder();
ConcurrentHashMap<Long, Long> m = longMap();
m.forEachKey(Long.MAX_VALUE, (Long x) -> adder.add(x.longValue()));
assertEquals(adder.sum(), SIZE * (SIZE - 1) / 2);
}
use of java.util.concurrent.atomic.LongAdder in project spring-boot by spring-projects.
the class BufferGaugeServiceSpeedTests method reader.
@Theory
public void reader(String input) throws Exception {
iterate("writeReader");
double rate = number / watch.getLastTaskTimeMillis() * 1000;
System.err.println("Rate(" + count + ")=" + rate + ", " + watch);
watch.start("readReader" + count);
this.reader.findAll().forEach(new Consumer<Metric<?>>() {
@Override
public void accept(Metric<?> metric) {
err.println(metric);
}
});
final LongAdder total = new LongAdder();
this.reader.findAll().forEach(new Consumer<Metric<?>>() {
@Override
public void accept(Metric<?> value) {
total.add(value.getValue().intValue());
}
});
watch.stop();
System.err.println("Read(" + count + ")=" + watch.getLastTaskTimeMillis() + "ms");
assertThat(0 < total.longValue()).isTrue();
}
Aggregations