Example #1
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);
        }
Example #2
0
        public long Run(ThroughputSessionContext sessionContext)
        {
            var latch = new ManualResetEvent(false);

            _queueProcessor.Reset(latch);
            var future = Task.Run(() => _queueProcessor.Run());

            sessionContext.Start();

            for (long i = 0; i < _iterations; i++)
            {
                _blockingQueue.Enqueue(3L);
            }

            latch.WaitOne();
            sessionContext.Stop();
            _queueProcessor.Halt();
            future.Wait();

            PerfTestUtil.FailIf(_expectedResult, 0);

            return(_iterations);
        }