use of java8.util.concurrent.atomic.LongAdder in project streamsupport by stefan-zobel.
the class LongAdderTest method testIncrementAndSum.
/**
* incrementAndGet increments and returns current value
*/
public void testIncrementAndSum() {
LongAdder ai = new LongAdder();
ai.increment();
assertEquals(1, ai.sum());
ai.increment();
assertEquals(2, ai.sum());
}
use of java8.util.concurrent.atomic.LongAdder in project streamsupport by stefan-zobel.
the class LongAdderTest method testLongValue.
/**
* longValue returns current value.
*/
public void testLongValue() {
LongAdder ai = new LongAdder();
assertEquals(0, ai.longValue());
ai.increment();
assertEquals(1, ai.longValue());
}
use of java8.util.concurrent.atomic.LongAdder in project streamsupport by stefan-zobel.
the class LongAdderTest method testDoubleValue.
/**
* doubleValue returns current value.
*/
public void testDoubleValue() {
LongAdder ai = new LongAdder();
assertEquals(0.0, ai.doubleValue());
ai.increment();
assertEquals(1.0, ai.doubleValue());
}
use of java8.util.concurrent.atomic.LongAdder in project streamsupport by stefan-zobel.
the class SplittableRandomTest method testUnsizedDoublesCount.
/**
* A parallel unsized stream of doubles generates at least 100 values
*/
public void testUnsizedDoublesCount() {
LongAdder counter = new LongAdder();
SplittableRandom r = new SplittableRandom();
long size = 100;
r.doubles().limit(size).parallel().forEach(x -> counter.increment());
assertEquals(size, counter.sum());
}
use of java8.util.concurrent.atomic.LongAdder in project streamsupport by stefan-zobel.
the class SplittableRandomTest method testUnsizedDoublesCountSeq.
/**
* A sequential unsized stream of doubles generates at least 100 values
*/
public void testUnsizedDoublesCountSeq() {
LongAdder counter = new LongAdder();
SplittableRandom r = new SplittableRandom();
long size = 100;
r.doubles().limit(size).forEach(x -> counter.increment());
assertEquals(size, counter.sum());
}
Aggregations