Search in sources :

Example 41 with Theory

use of org.junit.experimental.theories.Theory 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();
}
Also used : DoubleAdder(java.util.concurrent.atomic.DoubleAdder) Theory(org.junit.experimental.theories.Theory)

Example 42 with Theory

use of org.junit.experimental.theories.Theory 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();
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder) Metric(org.springframework.boot.actuate.metrics.Metric) Theory(org.junit.experimental.theories.Theory)

Example 43 with Theory

use of org.junit.experimental.theories.Theory in project spring-boot by spring-projects.

the class CounterServiceSpeedTests 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(total.longValue()).isEqualTo(number * threadCount);
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder) Metric(org.springframework.boot.actuate.metrics.Metric) Theory(org.junit.experimental.theories.Theory)

Example 44 with Theory

use of org.junit.experimental.theories.Theory in project spring-boot by spring-projects.

the class DefaultGaugeServiceSpeedTests method gauges.

@Theory
public void gauges(String input) throws Exception {
    watch.start("gauges" + count++);
    ExecutorService pool = Executors.newFixedThreadPool(threadCount);
    Runnable task = new Runnable() {

        @Override
        public void run() {
            for (int i = 0; i < number; i++) {
                String name = sample[i % sample.length];
                DefaultGaugeServiceSpeedTests.this.gaugeService.submit(name, count + i);
            }
        }
    };
    Collection<Future<?>> futures = new HashSet<>();
    for (int i = 0; i < threadCount; i++) {
        futures.add(pool.submit(task));
    }
    for (Future<?> future : futures) {
        future.get();
    }
    watch.stop();
    double rate = number / watch.getLastTaskTimeMillis() * 1000;
    System.err.println("Gauges rate(" + count + ")=" + rate + ", " + watch);
    watch.start("read" + 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();
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) Metric(org.springframework.boot.actuate.metrics.Metric) HashSet(java.util.HashSet) Theory(org.junit.experimental.theories.Theory)

Example 45 with Theory

use of org.junit.experimental.theories.Theory in project spring-boot by spring-projects.

the class DropwizardCounterServiceSpeedTests method counters.

@Theory
public void counters(String input) throws Exception {
    watch.start("counters" + count++);
    ExecutorService pool = Executors.newFixedThreadPool(threadCount);
    Runnable task = new Runnable() {

        @Override
        public void run() {
            for (int i = 0; i < number; i++) {
                String name = sample[i % sample.length];
                DropwizardCounterServiceSpeedTests.this.counterService.increment(name);
            }
        }
    };
    Collection<Future<?>> futures = new HashSet<>();
    for (int i = 0; i < threadCount; i++) {
        futures.add(pool.submit(task));
    }
    for (Future<?> future : futures) {
        future.get();
    }
    watch.stop();
    double rate = number / watch.getLastTaskTimeMillis() * 1000;
    System.err.println("Counters rate(" + count + ")=" + rate + ", " + watch);
    watch.start("read" + 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);
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) Metric(org.springframework.boot.actuate.metrics.Metric) HashSet(java.util.HashSet) Theory(org.junit.experimental.theories.Theory)

Aggregations

Theory (org.junit.experimental.theories.Theory)107 DataPoint (org.junit.experimental.theories.DataPoint)23 Test (org.junit.Test)22 Header (io.aeron.logbuffer.Header)15 DirectBuffer (org.agrona.DirectBuffer)15 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)13 DebugReceiveChannelEndpoint (io.aeron.driver.ext.DebugReceiveChannelEndpoint)11 DebugSendChannelEndpoint (io.aeron.driver.ext.DebugSendChannelEndpoint)11 UdpChannel (io.aeron.driver.media.UdpChannel)11 MediaDriver (io.aeron.driver.MediaDriver)8 Lock (java.util.concurrent.locks.Lock)7 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)7 LongAdder (java.util.concurrent.atomic.LongAdder)6 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)6 PrimitiveCollection (org.neo4j.collection.primitive.PrimitiveCollection)6 InOrder (org.mockito.InOrder)5 InputStream (java.io.InputStream)4 BaseStream (java.util.stream.BaseStream)4 InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)4 Metric (org.springframework.boot.actuate.metrics.Metric)4