java.util.concurrent.atomic.LongAdder

Here are the examples of the java api class java.util.concurrent.atomic.LongAdder taken from open source projects.

1. ConcurrentHashMap8Test#testKeySetSpliterator()

View license
/**
     * KeySetView.spliterator returns spliterator over the elements in this set
     */
public void testKeySetSpliterator() {
    LongAdder adder = new LongAdder();
    ConcurrentMap map = map5();
    Set set = map.keySet();
    Spliterator<Integer> sp = set.spliterator();
    checkSpliteratorCharacteristics(sp, CONCURRENT | DISTINCT | NONNULL);
    assertEquals(sp.estimateSize(), map.size());
    Spliterator<Integer> sp2 = sp.trySplit();
    sp.forEachRemaining((Integer x) -> adder.add(x.longValue()));
    long v = adder.sumThenReset();
    sp2.forEachRemaining((Integer x) -> adder.add(x.longValue()));
    long v2 = adder.sum();
    assertEquals(v + v2, 15);
}

2. ConcurrentHashMap8Test#testKeySetSpliterator()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * KeySetView.spliterator returns spliterator over the elements in this set
     */
public void testKeySetSpliterator() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap map = map5();
    Set set = map.keySet();
    Spliterator<Integer> sp = set.spliterator();
    checkSpliteratorCharacteristics(sp, CONCURRENT | DISTINCT | NONNULL);
    assertEquals(sp.estimateSize(), map.size());
    Spliterator<Integer> sp2 = sp.trySplit();
    sp.forEachRemaining((Integer x) -> adder.add(x.longValue()));
    long v = adder.sumThenReset();
    sp2.forEachRemaining((Integer x) -> adder.add(x.longValue()));
    long v2 = adder.sum();
    assertEquals(v + v2, 15);
}

3. ConcurrentHashMap8Test#testKeySetSpliterator()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * KeySetView.spliterator returns spliterator over the elements in this set
     */
public void testKeySetSpliterator() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap map = map5();
    Set set = map.keySet();
    Spliterator<Integer> sp = set.spliterator();
    checkSpliteratorCharacteristics(sp, CONCURRENT | DISTINCT | NONNULL);
    assertEquals(sp.estimateSize(), map.size());
    Spliterator<Integer> sp2 = sp.trySplit();
    sp.forEachRemaining((Integer x) -> adder.add(x.longValue()));
    long v = adder.sumThenReset();
    sp2.forEachRemaining((Integer x) -> adder.add(x.longValue()));
    long v2 = adder.sum();
    assertEquals(v + v2, 15);
}

4. LongAdderTest#testAddAndSumMT()

Project: openjdk
Source File: LongAdderTest.java
View license
/**
     * adds by multiple threads produce correct sum
     */
public void testAddAndSumMT() throws Throwable {
    final int incs = 1000000;
    final int nthreads = 4;
    final ExecutorService pool = Executors.newCachedThreadPool();
    LongAdder a = new LongAdder();
    CyclicBarrier barrier = new CyclicBarrier(nthreads + 1);
    for (int i = 0; i < nthreads; ++i) pool.execute(new AdderTask(a, barrier, incs));
    barrier.await();
    barrier.await();
    long total = (long) nthreads * incs;
    long sum = a.sum();
    assertEquals(sum, total);
    pool.shutdown();
}

5. ThreadLocalRandomTest#testIntsCount()

Project: openjdk
Source File: ThreadLocalRandomTest.java
View license
/**
     * A parallel sized stream of ints generates the given number of values
     */
public void testIntsCount() {
    LongAdder counter = new LongAdder();
    ThreadLocalRandom r = ThreadLocalRandom.current();
    long size = 0;
    for (int reps = 0; reps < REPS; ++reps) {
        counter.reset();
        r.ints(size).parallel().forEach( x -> {
            counter.increment();
        });
        assertEquals(counter.sum(), size);
        size += 524959;
    }
}

6. ThreadLocalRandomTest#testLongsCount()

Project: openjdk
Source File: ThreadLocalRandomTest.java
View license
/**
     * A parallel sized stream of longs generates the given number of values
     */
public void testLongsCount() {
    LongAdder counter = new LongAdder();
    ThreadLocalRandom r = ThreadLocalRandom.current();
    long size = 0;
    for (int reps = 0; reps < REPS; ++reps) {
        counter.reset();
        r.longs(size).parallel().forEach( x -> {
            counter.increment();
        });
        assertEquals(counter.sum(), size);
        size += 524959;
    }
}

7. ThreadLocalRandomTest#testDoublesCount()

Project: openjdk
Source File: ThreadLocalRandomTest.java
View license
/**
     * A parallel sized stream of doubles generates the given number of values
     */
public void testDoublesCount() {
    LongAdder counter = new LongAdder();
    ThreadLocalRandom r = ThreadLocalRandom.current();
    long size = 0;
    for (int reps = 0; reps < REPS; ++reps) {
        counter.reset();
        r.doubles(size).parallel().forEach( x -> {
            counter.increment();
        });
        assertEquals(counter.sum(), size);
        size += 524959;
    }
}

8. RandomTest#testIntsCount()

Project: openjdk
Source File: RandomTest.java
View license
/**
     * 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;
    }
}

9. RandomTest#testLongsCount()

Project: openjdk
Source File: RandomTest.java
View license
/**
     * 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;
    }
}

10. RandomTest#testDoublesCount()

Project: openjdk
Source File: RandomTest.java
View license
/**
     * A sequential sized stream of doubles generates the given number of values
     */
public void testDoublesCount() {
    LongAdder counter = new LongAdder();
    Random r = new Random();
    long size = 0;
    for (int reps = 0; reps < REPS; ++reps) {
        counter.reset();
        r.doubles(size).forEach( x -> {
            counter.increment();
        });
        assertEquals(counter.sum(), size);
        size += 524959;
    }
}

11. RedisBFPerformance#compareToRuby()

View license
private static void compareToRuby(int count, int items, BloomFilter<String> b) {
    b.clear();
    Random r = new Random();
    LongAdder fp = new LongAdder();
    Set<String> seen = Collections.newSetFromMap(new ConcurrentHashMap<>());
    long start = System.currentTimeMillis();
    IntStream.range(0, count).parallel().forEach( i -> {
        String element = String.valueOf(r.nextInt(items));
        if (b.contains(element) && !seen.contains(element))
            fp.increment();
        b.add(element);
        seen.add(element);
    });
    double fprate = 100.0 * fp.intValue() / count;
    System.out.println("False Positives = " + fp + ", FP-Rate = " + fprate);
    long end = System.currentTimeMillis();
    MemoryBFTest.printStat(start, end, count);
}

12. BufferGaugeServiceSpeedTests#reader()

View license
@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();
}

13. CounterServiceSpeedTests#reader()

View license
@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(total.longValue()).isEqualTo(number * threadCount);
}

14. LongAdderTest#testSerialization()

Project: openjdk
Source File: LongAdderTest.java
View license
/**
     * a deserialized serialized adder holds same value
     */
public void testSerialization() throws Exception {
    LongAdder x = new LongAdder();
    LongAdder y = serialClone(x);
    assertNotSame(x, y);
    x.add(-22);
    LongAdder z = serialClone(x);
    assertNotSame(y, z);
    assertEquals(-22, x.sum());
    assertEquals(0, y.sum());
    assertEquals(-22, z.sum());
}

15. Serial#testLongAdder()

Project: openjdk
Source File: Serial.java
View license
static void testLongAdder() {
    LongAdder a = new LongAdder();
    a.add(45);
    LongAdder result = echo(a);
    if (result.longValue() != a.longValue())
        throw new RuntimeException("Unexpected longValue");
    checkSerialClassName(a, "java.util.concurrent.atomic.LongAdder$SerializationProxy");
}

16. LongAdderTest#testAddAndSum()

Project: openjdk
Source File: LongAdderTest.java
View license
/**
     * add adds given value to current, and sum returns current value
     */
public void testAddAndSum() {
    LongAdder ai = new LongAdder();
    ai.add(2);
    assertEquals(2, ai.sum());
    ai.add(-4);
    assertEquals(-2, ai.sum());
}

17. LongAdderTest#testDecrementAndsum()

Project: openjdk
Source File: LongAdderTest.java
View license
/**
     * decrement decrements and sum returns current value
     */
public void testDecrementAndsum() {
    LongAdder ai = new LongAdder();
    ai.decrement();
    assertEquals(-1, ai.sum());
    ai.decrement();
    assertEquals(-2, ai.sum());
}

18. LongAdderTest#testIncrementAndsum()

Project: openjdk
Source File: LongAdderTest.java
View license
/**
     * 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());
}

19. LongAdderTest#testReset()

Project: openjdk
Source File: LongAdderTest.java
View license
/**
     * reset() causes subsequent sum() to return zero
     */
public void testReset() {
    LongAdder ai = new LongAdder();
    ai.add(2);
    assertEquals(2, ai.sum());
    ai.reset();
    assertEquals(0, ai.sum());
}

20. CategoryManager#getCategoryCountHelper()

Project: autopsy
Source File: CategoryManager.java
View license
/**
     * helper method that looks up the number of files with the given Category
     * from the db and wraps it in a long adder to use in the cache
     *
     *
     * @param cat the Category to count
     *
     * @return a LongAdder whose value is set to the number of file with the
     *         given Category
     */
private synchronized LongAdder getCategoryCountHelper(Category cat) {
    LongAdder longAdder = new LongAdder();
    longAdder.decrement();
    try {
        longAdder.add(db.getCategoryCount(cat));
        longAdder.increment();
    } catch (IllegalStateException ex) {
        LOGGER.log(Level.WARNING, "Case closed while getting files");
    }
    return longAdder;
}

21. LongAdderTest#testSumThenReset()

Project: openjdk
Source File: LongAdderTest.java
View license
/**
     * sumThenReset() returns sum; subsequent sum() returns zero
     */
public void testSumThenReset() {
    LongAdder ai = new LongAdder();
    ai.add(2);
    assertEquals(2, ai.sum());
    assertEquals(2, ai.sumThenReset());
    assertEquals(0, ai.sum());
}

22. LongAdderTest#testToString()

Project: openjdk
Source File: LongAdderTest.java
View license
/**
     * toString returns current value.
     */
public void testToString() {
    LongAdder ai = new LongAdder();
    assertEquals("0", ai.toString());
    ai.increment();
    assertEquals(Long.toString(1), ai.toString());
}

23. LongAdderTest#testIntValue()

Project: openjdk
Source File: LongAdderTest.java
View license
/**
     * intValue returns current value.
     */
public void testIntValue() {
    LongAdder ai = new LongAdder();
    assertEquals(0, ai.intValue());
    ai.increment();
    assertEquals(1, ai.intValue());
}

24. LongAdderTest#testLongValue()

Project: openjdk
Source File: LongAdderTest.java
View license
/**
     * longValue returns current value.
     */
public void testLongValue() {
    LongAdder ai = new LongAdder();
    assertEquals(0, ai.longValue());
    ai.increment();
    assertEquals(1, ai.longValue());
}

25. LongAdderTest#testFloatValue()

Project: openjdk
Source File: LongAdderTest.java
View license
/**
     * floatValue returns current value.
     */
public void testFloatValue() {
    LongAdder ai = new LongAdder();
    assertEquals(0.0f, ai.floatValue());
    ai.increment();
    assertEquals(1.0f, ai.floatValue());
}

26. LongAdderTest#testDoubleValue()

Project: openjdk
Source File: LongAdderTest.java
View license
/**
     * doubleValue returns current value.
     */
public void testDoubleValue() {
    LongAdder ai = new LongAdder();
    assertEquals(0.0, ai.doubleValue());
    ai.increment();
    assertEquals(1.0, ai.doubleValue());
}

27. ConcurrentHashMap8Test#testForEachKeySequentially()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * 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);
}

28. ConcurrentHashMap8Test#testForEachValueSequentially()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * forEachValueSequentially traverses all values
     */
public void testForEachValueSequentially() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachValue(Long.MAX_VALUE, (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), SIZE * (SIZE - 1));
}

29. ConcurrentHashMap8Test#testForEachSequentially()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * 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);
}

30. ConcurrentHashMap8Test#testForEachEntrySequentially()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * forEachEntrySequentially traverses all entries
     */
public void testForEachEntrySequentially() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachEntry(Long.MAX_VALUE, (Map.Entry<Long, Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue()));
    assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}

31. ConcurrentHashMap8Test#testForEachKeyInParallel()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * forEachKeyInParallel traverses all keys
     */
public void testForEachKeyInParallel() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachKey(1L, (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), SIZE * (SIZE - 1) / 2);
}

32. ConcurrentHashMap8Test#testForEachValueInParallel()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * 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));
}

33. ConcurrentHashMap8Test#testForEachInParallel()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * forEachInParallel traverses all mappings
     */
public void testForEachInParallel() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEach(1L, (Long x, Long y) -> adder.add(x.longValue() + y.longValue()));
    assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}

34. ConcurrentHashMap8Test#testForEachEntryInParallel()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * forEachEntryInParallel traverses all entries
     */
public void testForEachEntryInParallel() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachEntry(1L, (Map.Entry<Long, Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue()));
    assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}

35. ConcurrentHashMap8Test#testMappedForEachKeySequentially()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * 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);
}

36. ConcurrentHashMap8Test#testMappedForEachValueSequentially()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * Mapped forEachValueSequentially traverses the given
     * transformations of all values
     */
public void testMappedForEachValueSequentially() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachValue(Long.MAX_VALUE, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1));
}

37. ConcurrentHashMap8Test#testMappedForEachSequentially()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * Mapped forEachSequentially traverses the given
     * transformations of all mappings
     */
public void testMappedForEachSequentially() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEach(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()), (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}

38. ConcurrentHashMap8Test#testMappedForEachEntrySequentially()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * Mapped forEachEntrySequentially traverses the given
     * transformations of all entries
     */
public void testMappedForEachEntrySequentially() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachEntry(Long.MAX_VALUE, (Map.Entry<Long, Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()), (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}

39. ConcurrentHashMap8Test#testMappedForEachKeyInParallel()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * Mapped forEachKeyInParallel traverses the given
     * transformations of all keys
     */
public void testMappedForEachKeyInParallel() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachKey(1L, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1) / 2);
}

40. ConcurrentHashMap8Test#testMappedForEachValueInParallel()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * Mapped forEachValueInParallel traverses the given
     * transformations of all values
     */
public void testMappedForEachValueInParallel() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachValue(1L, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1));
}

41. ConcurrentHashMap8Test#testMappedForEachInParallel()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * Mapped forEachInParallel traverses the given
     * transformations of all mappings
     */
public void testMappedForEachInParallel() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEach(1L, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()), (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}

42. ConcurrentHashMap8Test#testMappedForEachEntryInParallel()

Project: mapdb
Source File: ConcurrentHashMap8Test.java
View license
/**
     * Mapped forEachEntryInParallel traverses the given
     * transformations of all entries
     */
public void testMappedForEachEntryInParallel() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachEntry(1L, (Map.Entry<Long, Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()), (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}

43. AccessIdUtil#getIncrement()

Project: Mycat-openEP
Source File: AccessIdUtil.java
View license
private static LongAdder getIncrement() {
    LongAdder adder = increment.get();
    if (adder == null) {
        adder = new LongAdder();
        increment.set(adder);
    }
    return adder;
}

44. AccessIdUtil#serialNum()

Project: Mycat-openEP
Source File: AccessIdUtil.java
View license
private static String serialNum() {
    LongAdder adder = getIncrement();
    try {
        return Long.toString(adder.longValue(), 36);
    } finally {
        adder.increment();
    }
}

45. AccessIdUtil#getIncrement()

Project: Mycat-openEP
Source File: AccessIdUtil.java
View license
private static LongAdder getIncrement() {
    LongAdder adder = increment.get();
    if (adder == null) {
        adder = new LongAdder();
        increment.set(adder);
    }
    return adder;
}

46. AccessIdUtil#serialNum()

Project: Mycat-openEP
Source File: AccessIdUtil.java
View license
private static String serialNum() {
    LongAdder adder = getIncrement();
    try {
        return Long.toString(adder.longValue(), 36);
    } finally {
        adder.increment();
    }
}

47. LongAdderDemo#adderTest()

Project: openjdk
Source File: LongAdderDemo.java
View license
static void adderTest(int nthreads, int incs) {
    System.out.print("LongAdder  ");
    Phaser phaser = new Phaser(nthreads + 1);
    LongAdder a = new LongAdder();
    for (int i = 0; i < nthreads; ++i) pool.execute(new AdderTask(a, phaser, incs));
    report(nthreads, incs, timeTasks(phaser), a.sum());
}

48. ConcurrentHashMap8Test#testForEachKeySequentially()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * 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);
}

49. ConcurrentHashMap8Test#testForEachValueSequentially()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * forEachValueSequentially traverses all values
     */
public void testForEachValueSequentially() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachValue(Long.MAX_VALUE, (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), SIZE * (SIZE - 1));
}

50. ConcurrentHashMap8Test#testForEachSequentially()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * 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);
}

51. ConcurrentHashMap8Test#testForEachEntrySequentially()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * forEachEntrySequentially traverses all entries
     */
public void testForEachEntrySequentially() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachEntry(Long.MAX_VALUE, (Map.Entry<Long, Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue()));
    assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}

52. ConcurrentHashMap8Test#testForEachKeyInParallel()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * forEachKeyInParallel traverses all keys
     */
public void testForEachKeyInParallel() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachKey(1L, (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), SIZE * (SIZE - 1) / 2);
}

53. ConcurrentHashMap8Test#testForEachValueInParallel()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * 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));
}

54. ConcurrentHashMap8Test#testForEachInParallel()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * forEachInParallel traverses all mappings
     */
public void testForEachInParallel() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEach(1L, (Long x, Long y) -> adder.add(x.longValue() + y.longValue()));
    assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}

55. ConcurrentHashMap8Test#testForEachEntryInParallel()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * forEachEntryInParallel traverses all entries
     */
public void testForEachEntryInParallel() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachEntry(1L, (Map.Entry<Long, Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue()));
    assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}

56. ConcurrentHashMap8Test#testMappedForEachKeySequentially()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * 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);
}

57. ConcurrentHashMap8Test#testMappedForEachValueSequentially()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * Mapped forEachValueSequentially traverses the given
     * transformations of all values
     */
public void testMappedForEachValueSequentially() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachValue(Long.MAX_VALUE, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1));
}

58. ConcurrentHashMap8Test#testMappedForEachSequentially()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * Mapped forEachSequentially traverses the given
     * transformations of all mappings
     */
public void testMappedForEachSequentially() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEach(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()), (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}

59. ConcurrentHashMap8Test#testMappedForEachEntrySequentially()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * Mapped forEachEntrySequentially traverses the given
     * transformations of all entries
     */
public void testMappedForEachEntrySequentially() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachEntry(Long.MAX_VALUE, (Map.Entry<Long, Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()), (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}

60. ConcurrentHashMap8Test#testMappedForEachKeyInParallel()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * Mapped forEachKeyInParallel traverses the given
     * transformations of all keys
     */
public void testMappedForEachKeyInParallel() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachKey(1L, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1) / 2);
}

61. ConcurrentHashMap8Test#testMappedForEachValueInParallel()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * Mapped forEachValueInParallel traverses the given
     * transformations of all values
     */
public void testMappedForEachValueInParallel() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachValue(1L, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1));
}

62. ConcurrentHashMap8Test#testMappedForEachInParallel()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * Mapped forEachInParallel traverses the given
     * transformations of all mappings
     */
public void testMappedForEachInParallel() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEach(1L, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()), (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}

63. ConcurrentHashMap8Test#testMappedForEachEntryInParallel()

Project: openjdk
Source File: ConcurrentHashMap8Test.java
View license
/**
     * Mapped forEachEntryInParallel traverses the given
     * transformations of all entries
     */
public void testMappedForEachEntryInParallel() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachEntry(1L, (Map.Entry<Long, Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()), (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}

64. LongAdderTest#testConstructor()

Project: openjdk
Source File: LongAdderTest.java
View license
/**
     * default constructed initializes to zero
     */
public void testConstructor() {
    LongAdder ai = new LongAdder();
    assertEquals(0, ai.sum());
}

65. SplittableRandomTest#testIntsCount()

Project: openjdk
Source File: SplittableRandomTest.java
View license
/**
     * A parallel sized stream of ints generates the given number of values
     */
public void testIntsCount() {
    LongAdder counter = new LongAdder();
    SplittableRandom r = new SplittableRandom();
    long size = 0;
    for (int reps = 0; reps < REPS; ++reps) {
        counter.reset();
        r.ints(size).parallel().forEach( x -> counter.increment());
        assertEquals(size, counter.sum());
        size += 524959;
    }
}

66. SplittableRandomTest#testLongsCount()

Project: openjdk
Source File: SplittableRandomTest.java
View license
/**
     * A parallel sized stream of longs generates the given number of values
     */
public void testLongsCount() {
    LongAdder counter = new LongAdder();
    SplittableRandom r = new SplittableRandom();
    long size = 0;
    for (int reps = 0; reps < REPS; ++reps) {
        counter.reset();
        r.longs(size).parallel().forEach( x -> counter.increment());
        assertEquals(size, counter.sum());
        size += 524959;
    }
}

67. SplittableRandomTest#testDoublesCount()

Project: openjdk
Source File: SplittableRandomTest.java
View license
/**
     * A parallel sized stream of doubles generates the given number of values
     */
public void testDoublesCount() {
    LongAdder counter = new LongAdder();
    SplittableRandom r = new SplittableRandom();
    long size = 0;
    for (int reps = 0; reps < REPS; ++reps) {
        counter.reset();
        r.doubles(size).parallel().forEach( x -> counter.increment());
        assertEquals(size, counter.sum());
        size += 524959;
    }
}

68. SplittableRandomTest#testUnsizedIntsCount()

Project: openjdk
Source File: SplittableRandomTest.java
View license
/**
     * A parallel unsized stream of ints generates at least 100 values
     */
public void testUnsizedIntsCount() {
    LongAdder counter = new LongAdder();
    SplittableRandom r = new SplittableRandom();
    long size = 100;
    r.ints().limit(size).parallel().forEach( x -> counter.increment());
    assertEquals(size, counter.sum());
}

69. SplittableRandomTest#testUnsizedLongsCount()

Project: openjdk
Source File: SplittableRandomTest.java
View license
/**
     * A parallel unsized stream of longs generates at least 100 values
     */
public void testUnsizedLongsCount() {
    LongAdder counter = new LongAdder();
    SplittableRandom r = new SplittableRandom();
    long size = 100;
    r.longs().limit(size).parallel().forEach( x -> counter.increment());
    assertEquals(size, counter.sum());
}

70. SplittableRandomTest#testUnsizedDoublesCount()

Project: openjdk
Source File: SplittableRandomTest.java
View license
/**
     * 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());
}

71. SplittableRandomTest#testUnsizedIntsCountSeq()

Project: openjdk
Source File: SplittableRandomTest.java
View license
/**
     * A sequential unsized stream of ints generates at least 100 values
     */
public void testUnsizedIntsCountSeq() {
    LongAdder counter = new LongAdder();
    SplittableRandom r = new SplittableRandom();
    long size = 100;
    r.ints().limit(size).forEach( x -> counter.increment());
    assertEquals(size, counter.sum());
}

72. SplittableRandomTest#testUnsizedLongsCountSeq()

Project: openjdk
Source File: SplittableRandomTest.java
View license
/**
     * A sequential unsized stream of longs generates at least 100 values
     */
public void testUnsizedLongsCountSeq() {
    LongAdder counter = new LongAdder();
    SplittableRandom r = new SplittableRandom();
    long size = 100;
    r.longs().limit(size).forEach( x -> counter.increment());
    assertEquals(size, counter.sum());
}

73. SplittableRandomTest#testUnsizedDoublesCountSeq()

Project: openjdk
Source File: SplittableRandomTest.java
View license
/**
     * 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());
}

74. ThreadLocalRandom8Test#testIntsCount()

Project: openjdk
Source File: ThreadLocalRandom8Test.java
View license
/**
     * A parallel sized stream of ints generates the given number of values
     */
public void testIntsCount() {
    LongAdder counter = new LongAdder();
    ThreadLocalRandom r = ThreadLocalRandom.current();
    long size = 0;
    for (int reps = 0; reps < REPS; ++reps) {
        counter.reset();
        r.ints(size).parallel().forEach( x -> counter.increment());
        assertEquals(size, counter.sum());
        size += 524959;
    }
}

75. ThreadLocalRandom8Test#testLongsCount()

Project: openjdk
Source File: ThreadLocalRandom8Test.java
View license
/**
     * A parallel sized stream of longs generates the given number of values
     */
public void testLongsCount() {
    LongAdder counter = new LongAdder();
    ThreadLocalRandom r = ThreadLocalRandom.current();
    long size = 0;
    for (int reps = 0; reps < REPS; ++reps) {
        counter.reset();
        r.longs(size).parallel().forEach( x -> counter.increment());
        assertEquals(size, counter.sum());
        size += 524959;
    }
}

76. ThreadLocalRandom8Test#testDoublesCount()

Project: openjdk
Source File: ThreadLocalRandom8Test.java
View license
/**
     * A parallel sized stream of doubles generates the given number of values
     */
public void testDoublesCount() {
    LongAdder counter = new LongAdder();
    ThreadLocalRandom r = ThreadLocalRandom.current();
    long size = 0;
    for (int reps = 0; reps < REPS; ++reps) {
        counter.reset();
        r.doubles(size).parallel().forEach( x -> counter.increment());
        assertEquals(size, counter.sum());
        size += 524959;
    }
}

77. ThreadLocalRandom8Test#testUnsizedIntsCount()

Project: openjdk
Source File: ThreadLocalRandom8Test.java
View license
/**
     * A parallel unsized stream of ints generates at least 100 values
     */
public void testUnsizedIntsCount() {
    LongAdder counter = new LongAdder();
    ThreadLocalRandom r = ThreadLocalRandom.current();
    long size = 100;
    r.ints().limit(size).parallel().forEach( x -> counter.increment());
    assertEquals(size, counter.sum());
}

78. ThreadLocalRandom8Test#testUnsizedLongsCount()

Project: openjdk
Source File: ThreadLocalRandom8Test.java
View license
/**
     * A parallel unsized stream of longs generates at least 100 values
     */
public void testUnsizedLongsCount() {
    LongAdder counter = new LongAdder();
    ThreadLocalRandom r = ThreadLocalRandom.current();
    long size = 100;
    r.longs().limit(size).parallel().forEach( x -> counter.increment());
    assertEquals(size, counter.sum());
}

79. ThreadLocalRandom8Test#testUnsizedDoublesCount()

Project: openjdk
Source File: ThreadLocalRandom8Test.java
View license
/**
     * A parallel unsized stream of doubles generates at least 100 values
     */
public void testUnsizedDoublesCount() {
    LongAdder counter = new LongAdder();
    ThreadLocalRandom r = ThreadLocalRandom.current();
    long size = 100;
    r.doubles().limit(size).parallel().forEach( x -> counter.increment());
    assertEquals(size, counter.sum());
}

80. ThreadLocalRandom8Test#testUnsizedIntsCountSeq()

Project: openjdk
Source File: ThreadLocalRandom8Test.java
View license
/**
     * A sequential unsized stream of ints generates at least 100 values
     */
public void testUnsizedIntsCountSeq() {
    LongAdder counter = new LongAdder();
    ThreadLocalRandom r = ThreadLocalRandom.current();
    long size = 100;
    r.ints().limit(size).forEach( x -> counter.increment());
    assertEquals(size, counter.sum());
}

81. ThreadLocalRandom8Test#testUnsizedLongsCountSeq()

Project: openjdk
Source File: ThreadLocalRandom8Test.java
View license
/**
     * A sequential unsized stream of longs generates at least 100 values
     */
public void testUnsizedLongsCountSeq() {
    LongAdder counter = new LongAdder();
    ThreadLocalRandom r = ThreadLocalRandom.current();
    long size = 100;
    r.longs().limit(size).forEach( x -> counter.increment());
    assertEquals(size, counter.sum());
}

82. ThreadLocalRandom8Test#testUnsizedDoublesCountSeq()

Project: openjdk
Source File: ThreadLocalRandom8Test.java
View license
/**
     * A sequential unsized stream of doubles generates at least 100 values
     */
public void testUnsizedDoublesCountSeq() {
    LongAdder counter = new LongAdder();
    ThreadLocalRandom r = ThreadLocalRandom.current();
    long size = 100;
    r.doubles().limit(size).forEach( x -> counter.increment());
    assertEquals(size, counter.sum());
}

83. ThreadLocalRandomTest#testUnsizedIntsCount()

Project: openjdk
Source File: ThreadLocalRandomTest.java
View license
/**
     * A parallel unsized stream of ints generates at least 100 values
     */
public void testUnsizedIntsCount() {
    LongAdder counter = new LongAdder();
    ThreadLocalRandom r = ThreadLocalRandom.current();
    long size = 100;
    r.ints().limit(size).parallel().forEach( x -> {
        counter.increment();
    });
    assertEquals(counter.sum(), size);
}

84. ThreadLocalRandomTest#testUnsizedLongsCount()

Project: openjdk
Source File: ThreadLocalRandomTest.java
View license
/**
     * A parallel unsized stream of longs generates at least 100 values
     */
public void testUnsizedLongsCount() {
    LongAdder counter = new LongAdder();
    ThreadLocalRandom r = ThreadLocalRandom.current();
    long size = 100;
    r.longs().limit(size).parallel().forEach( x -> {
        counter.increment();
    });
    assertEquals(counter.sum(), size);
}

85. ThreadLocalRandomTest#testUnsizedDoublesCount()

Project: openjdk
Source File: ThreadLocalRandomTest.java
View license
/**
     * A parallel unsized stream of doubles generates at least 100 values
     */
public void testUnsizedDoublesCount() {
    LongAdder counter = new LongAdder();
    ThreadLocalRandom r = ThreadLocalRandom.current();
    long size = 100;
    r.doubles().limit(size).parallel().forEach( x -> {
        counter.increment();
    });
    assertEquals(counter.sum(), size);
}

86. ThreadLocalRandomTest#testUnsizedIntsCountSeq()

Project: openjdk
Source File: ThreadLocalRandomTest.java
View license
/**
     * A sequential unsized stream of ints generates at least 100 values
     */
public void testUnsizedIntsCountSeq() {
    LongAdder counter = new LongAdder();
    ThreadLocalRandom r = ThreadLocalRandom.current();
    long size = 100;
    r.ints().limit(size).forEach( x -> {
        counter.increment();
    });
    assertEquals(counter.sum(), size);
}

87. ThreadLocalRandomTest#testUnsizedLongsCountSeq()

Project: openjdk
Source File: ThreadLocalRandomTest.java
View license
/**
     * A sequential unsized stream of longs generates at least 100 values
     */
public void testUnsizedLongsCountSeq() {
    LongAdder counter = new LongAdder();
    ThreadLocalRandom r = ThreadLocalRandom.current();
    long size = 100;
    r.longs().limit(size).forEach( x -> {
        counter.increment();
    });
    assertEquals(counter.sum(), size);
}

88. ThreadLocalRandomTest#testUnsizedDoublesCountSeq()

Project: openjdk
Source File: ThreadLocalRandomTest.java
View license
/**
     * A sequential unsized stream of doubles generates at least 100 values
     */
public void testUnsizedDoublesCountSeq() {
    LongAdder counter = new LongAdder();
    ThreadLocalRandom r = ThreadLocalRandom.current();
    long size = 100;
    r.doubles().limit(size).forEach( x -> {
        counter.increment();
    });
    assertEquals(counter.sum(), size);
}

89. RandomTest#testUnsizedIntsCount()

Project: openjdk
Source File: RandomTest.java
View license
/**
     * A parallel unsized stream of ints generates at least 100 values
     */
public void testUnsizedIntsCount() {
    LongAdder counter = new LongAdder();
    Random r = new Random();
    long size = 100;
    r.ints().limit(size).parallel().forEach( x -> {
        counter.increment();
    });
    assertEquals(counter.sum(), size);
}

90. RandomTest#testUnsizedLongsCount()

Project: openjdk
Source File: RandomTest.java
View license
/**
     * A parallel unsized stream of longs generates at least 100 values
     */
public void testUnsizedLongsCount() {
    LongAdder counter = new LongAdder();
    Random r = new Random();
    long size = 100;
    r.longs().limit(size).parallel().forEach( x -> {
        counter.increment();
    });
    assertEquals(counter.sum(), size);
}

91. RandomTest#testUnsizedDoublesCount()

Project: openjdk
Source File: RandomTest.java
View license
/**
     * 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);
}

92. RandomTest#testUnsizedIntsCountSeq()

Project: openjdk
Source File: RandomTest.java
View license
/**
     * 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);
}

93. RandomTest#testUnsizedLongsCountSeq()

Project: openjdk
Source File: RandomTest.java
View license
/**
     * A sequential unsized stream of longs generates at least 100 values
     */
public void testUnsizedLongsCountSeq() {
    LongAdder counter = new LongAdder();
    Random r = new Random();
    long size = 100;
    r.longs().limit(size).forEach( x -> {
        counter.increment();
    });
    assertEquals(counter.sum(), size);
}

94. RandomTest#testUnsizedDoublesCountSeq()

Project: openjdk
Source File: RandomTest.java
View license
/**
     * A sequential unsized stream of doubles generates at least 100 values
     */
public void testUnsizedDoublesCountSeq() {
    LongAdder counter = new LongAdder();
    Random r = new Random();
    long size = 100;
    r.doubles().limit(size).forEach( x -> {
        counter.increment();
    });
    assertEquals(counter.sum(), size);
}

95. SplittableRandomTest#testIntsCount()

Project: openjdk
Source File: SplittableRandomTest.java
View license
/**
     * A parallel sized stream of ints generates the given number of values
     */
public void testIntsCount() {
    LongAdder counter = new LongAdder();
    SplittableRandom r = new SplittableRandom();
    long size = 0;
    for (int reps = 0; reps < REPS; ++reps) {
        counter.reset();
        r.ints(size).parallel().forEach( x -> {
            counter.increment();
        });
        assertEquals(counter.sum(), size);
        size += 524959;
    }
}

96. SplittableRandomTest#testLongsCount()

Project: openjdk
Source File: SplittableRandomTest.java
View license
/**
     * A parallel sized stream of longs generates the given number of values
     */
public void testLongsCount() {
    LongAdder counter = new LongAdder();
    SplittableRandom r = new SplittableRandom();
    long size = 0;
    for (int reps = 0; reps < REPS; ++reps) {
        counter.reset();
        r.longs(size).parallel().forEach( x -> {
            counter.increment();
        });
        assertEquals(counter.sum(), size);
        size += 524959;
    }
}

97. SplittableRandomTest#testDoublesCount()

Project: openjdk
Source File: SplittableRandomTest.java
View license
/**
     * A parallel sized stream of doubles generates the given number of values
     */
public void testDoublesCount() {
    LongAdder counter = new LongAdder();
    SplittableRandom r = new SplittableRandom();
    long size = 0;
    for (int reps = 0; reps < REPS; ++reps) {
        counter.reset();
        r.doubles(size).parallel().forEach( x -> {
            counter.increment();
        });
        assertEquals(counter.sum(), size);
        size += 524959;
    }
}

98. SplittableRandomTest#testUnsizedIntsCount()

Project: openjdk
Source File: SplittableRandomTest.java
View license
/**
     * A parallel unsized stream of ints generates at least 100 values
     */
public void testUnsizedIntsCount() {
    LongAdder counter = new LongAdder();
    SplittableRandom r = new SplittableRandom();
    long size = 100;
    r.ints().limit(size).parallel().forEach( x -> {
        counter.increment();
    });
    assertEquals(counter.sum(), size);
}

99. SplittableRandomTest#testUnsizedLongsCount()

Project: openjdk
Source File: SplittableRandomTest.java
View license
/**
     * A parallel unsized stream of longs generates at least 100 values
     */
public void testUnsizedLongsCount() {
    LongAdder counter = new LongAdder();
    SplittableRandom r = new SplittableRandom();
    long size = 100;
    r.longs().limit(size).parallel().forEach( x -> {
        counter.increment();
    });
    assertEquals(counter.sum(), size);
}

100. SplittableRandomTest#testUnsizedDoublesCount()

Project: openjdk
Source File: SplittableRandomTest.java
View license
/**
     * 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(counter.sum(), size);
}