Cleaned up warnings
parent
96f73f5dd9
commit
ba0ba341a1
|
@ -4,7 +4,7 @@ import dorkbox.benchmark.common.Base_BlockingQueue;
|
|||
import dorkbox.benchmark.common.Base_Queue;
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
public class Test_Queue_ArrayBlockingQueue extends Base_BlockingQueue {
|
||||
public class Test_Queue_ArrayBlockingQueue extends Base_BlockingQueue<Integer> {
|
||||
|
||||
public static final int REPETITIONS = 50 * 1000 * 100;
|
||||
|
||||
|
@ -16,7 +16,7 @@ public class Test_Queue_ArrayBlockingQueue extends Base_BlockingQueue {
|
|||
System.out.format("reps: %,d %s: \n", REPETITIONS, Test_Queue_ArrayBlockingQueue.class.getSimpleName());
|
||||
|
||||
for (int concurrency = 1; concurrency < 5; concurrency++) {
|
||||
final java.util.concurrent.ArrayBlockingQueue queue = new java.util.concurrent.ArrayBlockingQueue(1024);
|
||||
final java.util.concurrent.ArrayBlockingQueue<Integer> queue = new java.util.concurrent.ArrayBlockingQueue<Integer>(1024);
|
||||
final Integer initialValue = Integer.valueOf(777);
|
||||
new ABQ_Block().run(REPETITIONS, concurrency, concurrency, warmups, runs, bestRunsToAverage, false, queue,
|
||||
initialValue);
|
||||
|
|
|
@ -4,7 +4,7 @@ import dorkbox.benchmark.common.Base_BlockingQueue;
|
|||
import dorkbox.benchmark.common.Base_Queue;
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
public class Test_Queue_ConcurrentLinkedQueue extends Base_BlockingQueue {
|
||||
public class Test_Queue_ConcurrentLinkedQueue extends Base_BlockingQueue<Integer> {
|
||||
|
||||
public static final int REPETITIONS = 50 * 1000 * 100;
|
||||
|
||||
|
@ -16,7 +16,7 @@ public class Test_Queue_ConcurrentLinkedQueue extends Base_BlockingQueue {
|
|||
System.out.format("reps: %,d %s: \n", REPETITIONS, Test_Queue_ConcurrentLinkedQueue.class.getSimpleName());
|
||||
|
||||
for (int concurrency = 1; concurrency < 5; concurrency++) {
|
||||
final java.util.concurrent.ConcurrentLinkedQueue queue = new java.util.concurrent.ConcurrentLinkedQueue();
|
||||
final java.util.concurrent.ConcurrentLinkedQueue<Integer> queue = new java.util.concurrent.ConcurrentLinkedQueue<Integer>();
|
||||
final Integer initialValue = Integer.valueOf(777);
|
||||
new CLQ_NonBlock().run(REPETITIONS, concurrency, concurrency, warmups, runs, bestRunsToAverage, false, queue,
|
||||
initialValue);
|
||||
|
|
|
@ -15,14 +15,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
public
|
||||
class Test_Queue_Disruptor<T> {
|
||||
|
||||
private static final int AVAILABLE_PROCESSORS = Runtime.getRuntime().availableProcessors();
|
||||
private static boolean SHOW = true;
|
||||
|
||||
public static final int REPETITIONS = 50 * 1000 * 100;
|
||||
|
||||
private static final int bestRunsToAverage = 4;
|
||||
private static final int runs = 10;
|
||||
private static final int warmups = 0;
|
||||
|
||||
public static void main(final String[] args) throws Exception {
|
||||
System.out.format("reps: %,d %s: \n", REPETITIONS, "Disruptor");
|
||||
|
@ -52,7 +50,7 @@ class Test_Queue_Disruptor<T> {
|
|||
|
||||
for (int concurrency = 1; concurrency < 5; concurrency++) {
|
||||
final Integer initialValue = Integer.valueOf(777);
|
||||
new Test_Queue_Disruptor().run(REPETITIONS, concurrency, concurrency, runs, bestRunsToAverage, false,
|
||||
new Test_Queue_Disruptor<Integer>().run(REPETITIONS, concurrency, concurrency, runs, bestRunsToAverage, false,
|
||||
BUFFER_SIZE, strategy, initialValue);
|
||||
}
|
||||
}
|
||||
|
@ -202,7 +200,7 @@ class Test_Queue_Disruptor<T> {
|
|||
}
|
||||
|
||||
for (int i = 0; i < consumersCount; i++) {
|
||||
EventHandler h = (EventHandler) handlers[i];
|
||||
EventHandler<T> h = (EventHandler<T>) handlers[i];
|
||||
while (!h.isShutdown()) {
|
||||
Thread.yield();
|
||||
}
|
||||
|
@ -218,7 +216,7 @@ class Test_Queue_Disruptor<T> {
|
|||
}
|
||||
}
|
||||
for (int i = 0; i < consumersCount; i++) {
|
||||
EventHandler h = (EventHandler) handlers[i];
|
||||
EventHandler<T> h = (EventHandler<T>) handlers[i];
|
||||
final long end1 = h.getEnd();
|
||||
if (end1 - end > 0) {
|
||||
end = end1;
|
||||
|
@ -235,13 +233,13 @@ class Test_Queue_Disruptor<T> {
|
|||
}
|
||||
|
||||
|
||||
public class Producer<T> implements Runnable {
|
||||
private final RingBuffer<ValueHolder<T>> queue;
|
||||
public class Producer<TT> implements Runnable {
|
||||
private final RingBuffer<ValueHolder<TT>> queue;
|
||||
volatile long start;
|
||||
private int repetitions;
|
||||
private final T initialValue;
|
||||
private final TT initialValue;
|
||||
|
||||
public Producer(RingBuffer<ValueHolder<T>> queue, int repetitions, T initialValue) {
|
||||
public Producer(RingBuffer<ValueHolder<TT>> queue, int repetitions, TT initialValue) {
|
||||
this.queue = queue;
|
||||
this.repetitions = repetitions;
|
||||
this.initialValue = initialValue;
|
||||
|
@ -249,17 +247,17 @@ class Test_Queue_Disruptor<T> {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
RingBuffer<ValueHolder<T>> producer = this.queue;
|
||||
RingBuffer<ValueHolder<TT>> producer = this.queue;
|
||||
int i = this.repetitions;
|
||||
this.start = System.nanoTime();
|
||||
final T initialValue = this.initialValue;
|
||||
final TT initialValue = this.initialValue;
|
||||
|
||||
try {
|
||||
do {
|
||||
// setup the job
|
||||
final long seq = producer.next();
|
||||
// try {
|
||||
ValueHolder<T> eventJob = producer.get(seq);
|
||||
ValueHolder<TT> eventJob = producer.get(seq);
|
||||
eventJob.item = initialValue;
|
||||
// } finally {
|
||||
// always publish the job
|
||||
|
@ -295,26 +293,26 @@ class Test_Queue_Disruptor<T> {
|
|||
}
|
||||
|
||||
|
||||
class ValueFactory<T> implements EventFactory<ValueHolder<T>> {
|
||||
class ValueFactory<TT> implements EventFactory<ValueHolder<TT>> {
|
||||
|
||||
public ValueFactory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueHolder<T> newInstance() {
|
||||
return new ValueHolder<T>();
|
||||
public ValueHolder<TT> newInstance() {
|
||||
return new ValueHolder<TT>();
|
||||
}
|
||||
}
|
||||
|
||||
class ValueHolder<T> {
|
||||
class ValueHolder<TT> {
|
||||
|
||||
public T item = null;
|
||||
public TT item = null;
|
||||
|
||||
public ValueHolder() {}
|
||||
}
|
||||
|
||||
|
||||
class EventHandler<T> implements WorkHandler<ValueHolder<T>>, LifecycleAware{
|
||||
class EventHandler<TT> implements WorkHandler<ValueHolder<TT>>, LifecycleAware{
|
||||
AtomicBoolean shutdown = new AtomicBoolean(false);
|
||||
private long end = 0;
|
||||
|
||||
|
@ -330,7 +328,7 @@ class Test_Queue_Disruptor<T> {
|
|||
|
||||
@Override
|
||||
public
|
||||
void onEvent(final ValueHolder<T> event) throws Exception {
|
||||
void onEvent(final ValueHolder<TT> event) throws Exception {
|
||||
end = System.nanoTime();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ public class Test_Queue_LinkedBlockingQueue {
|
|||
System.out.format("reps: %,d %s\n", REPETITIONS, Test_Queue_LinkedBlockingQueue.class.getSimpleName());
|
||||
|
||||
for (int concurrency = 1; concurrency < 5; concurrency++) {
|
||||
final java.util.concurrent.LinkedBlockingQueue queue = new java.util.concurrent.LinkedBlockingQueue(1024);
|
||||
final java.util.concurrent.LinkedBlockingQueue<Integer> queue = new java.util.concurrent.LinkedBlockingQueue<Integer>(1024);
|
||||
final Integer initialValue = Integer.valueOf(777);
|
||||
new LBQ_Block().run(REPETITIONS, concurrency, concurrency, warmups, runs, bestRunsToAverage, false, queue,
|
||||
initialValue);
|
||||
|
@ -24,7 +24,7 @@ public class Test_Queue_LinkedBlockingQueue {
|
|||
System.out.println("");
|
||||
|
||||
for (int concurrency = 1; concurrency < 5; concurrency++) {
|
||||
final java.util.concurrent.LinkedBlockingQueue queue = new java.util.concurrent.LinkedBlockingQueue(1024);
|
||||
final java.util.concurrent.LinkedBlockingQueue<Integer> queue = new java.util.concurrent.LinkedBlockingQueue<Integer>(1024);
|
||||
final Integer initialValue = Integer.valueOf(777);
|
||||
new LBQ_NonBlock().run(REPETITIONS, concurrency, concurrency, warmups, runs, bestRunsToAverage, false, queue,
|
||||
initialValue);
|
||||
|
|
|
@ -4,7 +4,7 @@ import dorkbox.benchmark.common.Base_BlockingQueue;
|
|||
import dorkbox.benchmark.common.Base_Queue;
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
public class Test_Queue_MpmcArrayQueue extends Base_BlockingQueue {
|
||||
public class Test_Queue_MpmcArrayQueue extends Base_BlockingQueue<Integer> {
|
||||
|
||||
public static final int REPETITIONS = 50 * 1000 * 100;
|
||||
|
||||
|
@ -16,7 +16,7 @@ public class Test_Queue_MpmcArrayQueue extends Base_BlockingQueue {
|
|||
System.out.format("reps: %,d %s: \n", REPETITIONS, Test_Queue_MpmcArrayQueue.class.getSimpleName());
|
||||
|
||||
for (int concurrency = 1; concurrency < 5; concurrency++) {
|
||||
final org.jctools.queues.MpmcArrayQueue queue = new org.jctools.queues.MpmcArrayQueue(1 << 17);
|
||||
final org.jctools.queues.MpmcArrayQueue<Integer> queue = new org.jctools.queues.MpmcArrayQueue<Integer>(1 << 17);
|
||||
final Integer initialValue = Integer.valueOf(777);
|
||||
new MpmcArray_NonBlock().run(REPETITIONS, concurrency, concurrency, warmups, runs, bestRunsToAverage, false, queue,
|
||||
initialValue);
|
||||
|
|
|
@ -14,7 +14,7 @@ public class Test_Queue_SynchronousQueue {
|
|||
System.out.format("reps: %,d %s\n", REPETITIONS, Test_Queue_SynchronousQueue.class.getSimpleName());
|
||||
|
||||
for (int concurrency = 1; concurrency < 5; concurrency++) {
|
||||
final java.util.concurrent.SynchronousQueue queue = new java.util.concurrent.SynchronousQueue();
|
||||
final java.util.concurrent.SynchronousQueue<Integer> queue = new java.util.concurrent.SynchronousQueue<Integer>();
|
||||
final Integer initialValue = Integer.valueOf(777);
|
||||
new SQ_Block().run(REPETITIONS, concurrency, concurrency, warmups, runs, bestRunsToAverage, false, queue,
|
||||
initialValue);
|
||||
|
@ -24,7 +24,7 @@ public class Test_Queue_SynchronousQueue {
|
|||
System.out.println("");
|
||||
|
||||
for (int concurrency = 1; concurrency < 5; concurrency++) {
|
||||
final java.util.concurrent.SynchronousQueue queue = new java.util.concurrent.SynchronousQueue();
|
||||
final java.util.concurrent.SynchronousQueue<Integer> queue = new java.util.concurrent.SynchronousQueue<Integer>();
|
||||
final Integer initialValue = Integer.valueOf(777);
|
||||
new SQ_NonBlock().run(REPETITIONS, concurrency, concurrency, warmups, runs, bestRunsToAverage, false, queue,
|
||||
initialValue);
|
||||
|
|
|
@ -52,6 +52,7 @@ class Base_BlockingQueue<T> {
|
|||
* Benchmarks how long it takes to push X number of items total. If there are is 1P and 1C, then X items will be sent from a producer to
|
||||
* a consumer. Of there are NP and NC threads, then X/N (for a total of X) items will be sent.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private
|
||||
long performanceRun(final int runNumber,
|
||||
final BlockingQueue<T> queue,
|
||||
|
@ -69,8 +70,8 @@ class Base_BlockingQueue<T> {
|
|||
int cRepetitions = adjusted * consumersCount;
|
||||
|
||||
|
||||
Producer[] producers = new Producer[producersCount];
|
||||
Consumer[] consumers = new Consumer[consumersCount];
|
||||
Producer<T>[] producers = new Producer[producersCount];
|
||||
Consumer<T>[] consumers = new Consumer[consumersCount];
|
||||
|
||||
Thread[] pThreads = new Thread[producersCount];
|
||||
Thread[] cThreads = new Thread[consumersCount];
|
||||
|
|
|
@ -53,6 +53,7 @@ class Base_Queue<T> {
|
|||
* Benchmarks how long it takes to push X number of items total. If there are is 1P and 1C, then X items will be sent from a producer to
|
||||
* a consumer. Of there are NP and NC threads, then X/N (for a total of X) items will be sent.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private
|
||||
long performanceRun(final int runNumber,
|
||||
final Queue<T> queue,
|
||||
|
@ -70,8 +71,8 @@ class Base_Queue<T> {
|
|||
int cRepetitions = adjusted * consumersCount;
|
||||
|
||||
|
||||
Producer[] producers = new Producer[producersCount];
|
||||
Consumer[] consumers = new Consumer[consumersCount];
|
||||
Producer<T>[] producers = new Producer[producersCount];
|
||||
Consumer<T>[] consumers = new Consumer[consumersCount];
|
||||
|
||||
Thread[] pThreads = new Thread[producersCount];
|
||||
Thread[] cThreads = new Thread[consumersCount];
|
||||
|
|
|
@ -52,6 +52,7 @@ class Base_TransferQueue<T> {
|
|||
* Benchmarks how long it takes to push X number of items total. If there are is 1P and 1C, then X items will be sent from a producer to
|
||||
* a consumer. Of there are NP and NC threads, then X/N (for a total of X) items will be sent.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private
|
||||
long performanceRun(final int runNumber,
|
||||
final TransferQueue<T> queue,
|
||||
|
@ -69,8 +70,8 @@ class Base_TransferQueue<T> {
|
|||
int cRepetitions = adjusted * consumersCount;
|
||||
|
||||
|
||||
Producer[] producers = new Producer[producersCount];
|
||||
Consumer[] consumers = new Consumer[consumersCount];
|
||||
Producer<T>[] producers = new Producer[producersCount];
|
||||
Consumer<T>[] consumers = new Consumer[consumersCount];
|
||||
|
||||
Thread[] pThreads = new Thread[producersCount];
|
||||
Thread[] cThreads = new Thread[consumersCount];
|
||||
|
|
Loading…
Reference in New Issue