public void Setup() { _queue = new MPMCQueue(_bufferSize); for (var i = 0; i < Operations; i++) { _queue.TryEnqueue(_obj); } }
internal void MPMCBenchmark() { var count = 2_000_000; var threads = 4; var oddQueue = new MPMCQueue(128); var evenQueue = new MPMCQueue(128); using (Benchmark.Run("MPMCQueue", count * threads)) { Task.WaitAll(Enumerable.Range(0, threads).Select(i => { for (int j = 0; j < 4; j++) { oddQueue.Enqueue(new object()); evenQueue.Enqueue(new object()); } if (i % 2 == 0) { return(Task.Factory.StartNew(() => { for (int i = 0; i < count; i++) { object x1; do { x1 = evenQueue.Dequeue(); } while (x1 == null); while (!oddQueue.Enqueue(x1)) { } } }, TaskCreationOptions.LongRunning)); } else { return(Task.Factory.StartNew(() => { for (int i = 0; i < count; i++) { object x1; do { x1 = oddQueue.Dequeue(); } while (x1 == null); while (!evenQueue.Enqueue(x1)) { } } }, TaskCreationOptions.LongRunning)); } }).ToArray()); } }
public BoundedMailboxQueue(int size) { _messages = new MPMCQueue(size); }
public void Setup() { _queue = new MPMCQueue(_bufferSize); }
public RandomTests() { _queue = new MPMCQueue(65536); }
public MultiThreadedTests() { _queue = new MPMCQueue(_bufferSize); _threadsConsumers = LaunchConsumers(NumberOfThreads); _threads = LaunchProducers(Operations, NumberOfThreads); }