Search in sources :

Example 11 with LongAdder

use of java.util.concurrent.atomic.LongAdder in project jdk8u_jdk by JetBrains.

the class RandomTest method testIntsCount.

/**
     * A sequential sized stream of ints generates the given number of values
     */
public void testIntsCount() {
    LongAdder counter = new LongAdder();
    Random r = new Random();
    long size = 0;
    for (int reps = 0; reps < REPS; ++reps) {
        counter.reset();
        r.ints(size).forEach(x -> {
            counter.increment();
        });
        assertEquals(counter.sum(), size);
        size += 524959;
    }
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder) Random(java.util.Random)

Example 12 with LongAdder

use of java.util.concurrent.atomic.LongAdder in project jdk8u_jdk by JetBrains.

the class RandomTest method testUnsizedDoublesCount.

/**
     * A parallel unsized stream of doubles generates at least 100 values
     */
public void testUnsizedDoublesCount() {
    LongAdder counter = new LongAdder();
    Random r = new Random();
    long size = 100;
    r.doubles().limit(size).parallel().forEach(x -> {
        counter.increment();
    });
    assertEquals(counter.sum(), size);
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder) Random(java.util.Random)

Example 13 with LongAdder

use of java.util.concurrent.atomic.LongAdder in project jdk8u_jdk by JetBrains.

the class RandomTest method testUnsizedIntsCountSeq.

/**
     * A sequential unsized stream of ints generates at least 100 values
     */
public void testUnsizedIntsCountSeq() {
    LongAdder counter = new LongAdder();
    Random r = new Random();
    long size = 100;
    r.ints().limit(size).forEach(x -> {
        counter.increment();
    });
    assertEquals(counter.sum(), size);
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder) Random(java.util.Random)

Example 14 with LongAdder

use of java.util.concurrent.atomic.LongAdder in project jdk8u_jdk by JetBrains.

the class RandomTest method testLongsCount.

/**
     * A sequential sized stream of longs generates the given number of values
     */
public void testLongsCount() {
    LongAdder counter = new LongAdder();
    Random r = new Random();
    long size = 0;
    for (int reps = 0; reps < REPS; ++reps) {
        counter.reset();
        r.longs(size).forEach(x -> {
            counter.increment();
        });
        assertEquals(counter.sum(), size);
        size += 524959;
    }
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder) Random(java.util.Random)

Example 15 with LongAdder

use of java.util.concurrent.atomic.LongAdder in project jdk8u_jdk by JetBrains.

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(counter.sum(), size);
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder) SplittableRandom(java.util.SplittableRandom)

Aggregations

LongAdder (java.util.concurrent.atomic.LongAdder)92 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)16 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)16 Random (java.util.Random)13 ExecutorService (java.util.concurrent.ExecutorService)10 SplittableRandom (java.util.SplittableRandom)9 HashMap (java.util.HashMap)7 Map (java.util.Map)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 Theory (org.junit.experimental.theories.Theory)6 UUID (java.util.UUID)5 ArrayList (java.util.ArrayList)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 Ignite (org.apache.ignite.Ignite)4 IgniteUuid (org.apache.ignite.lang.IgniteUuid)4 Metric (org.springframework.boot.actuate.metrics.Metric)4 Date (java.util.Date)3 HashSet (java.util.HashSet)3 Callable (java.util.concurrent.Callable)3 CountDownLatch (java.util.concurrent.CountDownLatch)3