protected override long RunDisruptorPass()
        {
            CountdownEvent latch         = new CountdownEvent(1);
            long           expectedCount = batchEventProcessor.Sequence.Value + ITERATIONS;

            handler.Reset(latch, ITERATIONS);
            Task.Factory.StartNew(() => batchEventProcessor.Run());
            Stopwatch start = Stopwatch.StartNew();

            RingBuffer <long[]> rb = ringBuffer;

            for (long i = 0; i < ITERATIONS; i++)
            {
                long   next   = rb.Next();
                long[] @event = rb.Get(next);
                for (int j = 0; j < @event.Length; j++)
                {
                    @event[j] = i;
                }
                rb.Publish(next);
            }

            latch.Wait();
            long opsPerSecond = (ITERATIONS * ARRAY_SIZE * 1000L) / (start.ElapsedMilliseconds);

            waitForEventProcessorSequence(expectedCount);
            batchEventProcessor.Halt();

            PerfTestUtil.failIf(0, handler.Value);

            return(opsPerSecond);
        }
Пример #2
0
        protected override long RunQueuePass()
        {
            CountdownEvent latch = new CountdownEvent(1);

            queueProcessor.Reset(latch);
            CancellationTokenSource canncel = new CancellationTokenSource();

            Task.Factory.StartNew(() => queueProcessor.Run(), canncel.Token);

            var start = Stopwatch.StartNew();

            for (long i = 0; i < ITERATIONS; i++)
            {
                blockingQueue.Add(i);
            }

            latch.Wait();
            long opsPerSecond = (ITERATIONS * 1000L) / (start.ElapsedMilliseconds);

            queueProcessor.Halt();
            canncel.Cancel(true);

            PerfTestUtil.failIf(expectedResult, 0);

            return(opsPerSecond);
        }
Пример #3
0
        protected override long RunQueuePass()
        {
            CountdownEvent latch = new CountdownEvent(1);

            fizzBuzzQueueProcessor.Reset(latch);

            CancellationTokenSource cance = new CancellationTokenSource();
            var t1 = Task.Factory.StartNew(() => fizzQueueProcessor.Run(), cance.Token, TaskCreationOptions.None, TaskScheduler.Default);
            var t2 = Task.Factory.StartNew(() => buzzQueueProcessor.Run(), cance.Token, TaskCreationOptions.None, TaskScheduler.Default);
            var t3 = Task.Factory.StartNew(() => fizzBuzzQueueProcessor.Run(), cance.Token, TaskCreationOptions.None, TaskScheduler.Default);

            var run = Stopwatch.StartNew();

            for (long i = 0; i < ITERATIONS; i++)
            {
                fizzInputQueue.Enqueue(i);
                buzzInputQueue.Enqueue(i);
            }

            latch.Wait();
            long opsPerSecond = (ITERATIONS * 1000L) / run.ElapsedMilliseconds;

            fizzQueueProcessor.Halt();
            buzzQueueProcessor.Halt();
            fizzBuzzQueueProcessor.Halt();

            cance.Cancel();

            PerfTestUtil.failIf(ExpectedResult, 0);

            return(opsPerSecond);
        }
        protected override long RunQueuePass()
        {
            CountdownEvent latch = new CountdownEvent(1);

            stepThreeQueueProcessor.reset(latch);

            CancellationTokenSource cance = new CancellationTokenSource();
            var t1    = Task.Factory.StartNew(() => stepOneQueueProcessor.run(), cance.Token, TaskCreationOptions.None, TaskScheduler.Default);
            var t2    = Task.Factory.StartNew(() => stepTwoQueueProcessor.run(), cance.Token, TaskCreationOptions.None, TaskScheduler.Default);
            var t3    = Task.Factory.StartNew(() => stepThreeQueueProcessor.run(), cance.Token, TaskCreationOptions.None, TaskScheduler.Default);
            var start = Stopwatch.StartNew();

            long operandTwo = OPERAND_TWO_INITIAL_VALUE;

            for (long i = 0; i < ITERATIONS; i++)
            {
                long[] values = new long[2];
                values[0] = i;
                values[1] = operandTwo--;
                stepOneQueue.Enqueue(values);
            }
            latch.Wait();
            long opsPerSecond = (ITERATIONS * 1000L) / (start.ElapsedMilliseconds);

            stepOneQueueProcessor.halt();
            stepTwoQueueProcessor.halt();
            stepThreeQueueProcessor.halt();

            cance.Cancel();

            PerfTestUtil.failIf(expectedResult, 0);

            return(opsPerSecond);
        }
        protected override long RunQueuePass()
        {
            CountdownEvent latch = new CountdownEvent(NUM_EVENT_PROCESSORS);

            Task[] task = new Task[NUM_EVENT_PROCESSORS];
            CancellationTokenSource[] cancel = new CancellationTokenSource[NUM_EVENT_PROCESSORS];
            for (int i = 0; i < NUM_EVENT_PROCESSORS; i++)
            {
                queueProcessors[i].reset(latch);
                cancel[i] = new CancellationTokenSource();
                task[i]   = Task.Factory.StartNew(() => queueProcessors[i].run(), cancel[i].Token);
            }

            var start = Stopwatch.StartNew();

            for (long i = 0; i < ITERATIONS; i++)
            {
                long value = i;
                foreach (var queue in blockingQueues)
                {
                    queue.Enqueue(value);
                }
            }
            latch.Wait();

            long opsPerSecond = (ITERATIONS * 1000L) / (start.ElapsedMilliseconds);

            for (int i = 0; i < NUM_EVENT_PROCESSORS; i++)
            {
                queueProcessors[i].halt();
                cancel[i].Cancel();
                PerfTestUtil.failIf(queueProcessors[i].getValue(), -1);
            }

            return(opsPerSecond);
        }