use of java.util.concurrent.atomic.DoubleAdder in project fastjson by alibaba.
the class DoubleAdderTest method test_long_add.
public void test_long_add() throws Exception {
DoubleAdder adder = new DoubleAdder();
adder.add(3);
String json = JSON.toJSONString(adder);
assertEquals("{\"value\":3.0}", json);
}
use of java.util.concurrent.atomic.DoubleAdder in project spring-boot by spring-projects.
the class BufferGaugeServiceSpeedTests method raw.
@Theory
public void raw(String input) throws Exception {
iterate("writeRaw");
double rate = number / watch.getLastTaskTimeMillis() * 1000;
System.err.println("Rate(" + count + ")=" + rate + ", " + watch);
watch.start("readRaw" + count);
for (String name : names) {
this.gauges.forEach(Pattern.compile(name).asPredicate(), new BiConsumer<String, GaugeBuffer>() {
@Override
public void accept(String name, GaugeBuffer value) {
err.println(name + "=" + value);
}
});
}
final DoubleAdder total = new DoubleAdder();
this.gauges.forEach(Pattern.compile(".*").asPredicate(), new BiConsumer<String, GaugeBuffer>() {
@Override
public void accept(String name, GaugeBuffer value) {
total.add(value.getValue());
}
});
watch.stop();
System.err.println("Read(" + count + ")=" + watch.getLastTaskTimeMillis() + "ms");
assertThat(number * threadCount < total.longValue()).isTrue();
}
use of java.util.concurrent.atomic.DoubleAdder in project jdk8u_jdk by JetBrains.
the class Serial method testDoubleAdder.
static void testDoubleAdder() {
DoubleAdder a = new DoubleAdder();
a.add(20.1d);
DoubleAdder result = echo(a);
if (result.doubleValue() != a.doubleValue())
throw new RuntimeException("Unexpected doubleValue");
checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAdder$SerializationProxy");
}
use of java.util.concurrent.atomic.DoubleAdder in project jdk8u_jdk by JetBrains.
the class DoubleAdderDemo method adderTest.
static void adderTest(int nthreads, int incs) {
System.out.print("DoubleAdder ");
Phaser phaser = new Phaser(nthreads + 1);
DoubleAdder a = new DoubleAdder();
for (int i = 0; i < nthreads; ++i) pool.execute(new AdderTask(a, phaser, incs));
report(nthreads, incs, timeTasks(phaser), a.sum());
}
Aggregations