public UniCast1P1CDisruptorPerfTest() : base(100 * Million) { _disruptor = new Disruptor<ValueEvent>(() => new ValueEvent(),BufferSize,TaskScheduler.Default, ProducerType.SINGLE,new YieldingWaitStrategy()); _mru = new ManualResetEvent(false); _eventHandler = new ValueAdditionEventHandler(Iterations, _mru); _disruptor.HandleEventsWith(_eventHandler); _ringBuffer = _disruptor.GetRingBuffer; }
// [SetUp] public void Setup() { disruptor = new Disruptor<ValueEvent>(() => new ValueEvent() , 1024 * 8 , TaskScheduler.Default , ProducerType.SINGLE , new YieldingWaitStrategy() ); disruptor.HandleEventsWith(handlers); ringBuffer = disruptor.GetRingBuffer; }
//ÁâÐÎģʽ public DiamondPath1P3CDisruptorPerfTest() : base(100 * Million) { _disruptor = new Disruptor<FizzBuzzEvent>(() => new FizzBuzzEvent(), 1024*8, TaskScheduler.Default, ProducerType.SINGLE,new BlockingWaitStrategy()); _mru = new ManualResetEvent(false); _fizzEventHandler = new FizzBuzzEventHandler(FizzBuzzStep.Fizz, Iterations, _mru); _buzzEventHandler = new FizzBuzzEventHandler(FizzBuzzStep.Buzz, Iterations, _mru); _fizzBuzzEventHandler = new FizzBuzzEventHandler(FizzBuzzStep.FizzBuzz, Iterations, _mru); _disruptor.HandleEventsWith(_fizzEventHandler, _buzzEventHandler) .Then(_fizzBuzzEventHandler); _ringBuffer = _disruptor.GetRingBuffer; }
public void Start() { messageDisrupter = new Disruptor<RingbufferByteArray>(() => new RingbufferByteArray(), new SingleThreadedClaimStrategy(ringbufferSize), new SleepingWaitStrategy(), TaskScheduler.Default); // Switch to this line to use busy spin input queue //messageDisrupter = new Disruptor<RingbufferByteArray>(() => new RingbufferByteArray(), new SingleThreadedClaimStrategy(ringbufferSize), new BusySpinWaitStrategy(), TaskScheduler.Default); messageDisrupter.HandleEventsWith(messageProcessor).Then(performanceRecorder); messageDisrupter.HandleExceptionsWith(new IncomingMessageQueueErrorHandler()); messageRingBuffer = messageDisrupter.Start(); performanceRecorder.Setup(messageRingBuffer, 5000); logger.Info("Incoming message queue started."); }
public Pipeline3StepDisruptorPerfTest() : base(100 * Million) { _disruptor = new Disruptor<FunctionEvent>(() => new FunctionEvent(), Size, TaskScheduler.Default, ProducerType.SINGLE, new YieldingWaitStrategy()); ; _mru = new ManualResetEvent(false); _stepThreeFunctionEventHandler = new FunctionEventHandler(FunctionStep.Three, Iterations, _mru); _disruptor.HandleEventsWith(new FunctionEventHandler(FunctionStep.One, Iterations, _mru)) .Then(new FunctionEventHandler(FunctionStep.Two, Iterations, _mru)) .Then(_stepThreeFunctionEventHandler); _ringBuffer = _disruptor.GetRingBuffer; }
public Pipeline3StepLatencyDisruptorPerfTest() : base(2 * Million) { _disruptor = new Disruptor<ValueEvent>(() => new ValueEvent(), Size, TaskScheduler.Default, ProducerType.SINGLE, new YieldingWaitStrategy()); _mru = new ManualResetEvent(false); _stepOneFunctionEventHandler = new LatencyStepEventHandler(FunctionStep.One, Histogram, StopwatchTimestampCostInNano, TicksToNanos, Iterations, _mru); _stepTwoFunctionEventHandler = new LatencyStepEventHandler(FunctionStep.Two, Histogram, StopwatchTimestampCostInNano, TicksToNanos, Iterations, _mru); _stepThreeFunctionEventHandler = new LatencyStepEventHandler(FunctionStep.Three, Histogram, StopwatchTimestampCostInNano, TicksToNanos, Iterations, _mru); _disruptor.HandleEventsWith(_stepOneFunctionEventHandler) .Then(_stepTwoFunctionEventHandler) .Then(_stepThreeFunctionEventHandler); _ringBuffer = _disruptor.GetRingBuffer; }
public MultiCast1P3CDisruptorWithAffinityPerfTest() : base(100 * Million) { _scheduler = new RoundRobinThreadAffinedTaskScheduler(4); _disruptor = new Disruptor<ValueEvent>(() => new ValueEvent(), Size, _scheduler, ProducerType.MULTI, new YieldingWaitStrategy()); _latch = new CountdownEvent(3); _handler1 = new ValueMutationEventHandler(Operation.Addition, Iterations, _latch); _handler2 = new ValueMutationEventHandler(Operation.Substraction, Iterations, _latch); _handler3 = new ValueMutationEventHandler(Operation.And, Iterations, _latch); _disruptor.HandleEventsWith(_handler1, _handler2, _handler3); _ringBuffer = _disruptor.GetRingBuffer; }
public Pipeline3StepDisruptorWithAffinityPerfTest() : base(100 * Million)//1千万 1亿 { _scheduler = new RoundRobinThreadAffinedTaskScheduler(4); _disruptor = new Disruptor<FunctionEvent>(() => new FunctionEvent(),Size,_scheduler, ProducerType.SINGLE,new YieldingWaitStrategy()); _mru = new ManualResetEvent(false); _stepThreeFunctionEventHandler = new FunctionEventHandler(FunctionStep.Three, Iterations, _mru); _disruptor.HandleEventsWith(new FunctionEventHandler(FunctionStep.One, Iterations, _mru)) .Then(new FunctionEventHandler(FunctionStep.Two, Iterations, _mru)) .Then(_stepThreeFunctionEventHandler); _ringBuffer = _disruptor.GetRingBuffer; }
public Sequencer3P1CDisruptorPerfTest() : base(20 * Million) { _disruptor = new Disruptor<ValueEvent>(()=>new ValueEvent(),Size,TaskScheduler.Default, ProducerType.MULTI,new YieldingWaitStrategy()); _mru = new ManualResetEvent(false); _eventHandler = new ValueAdditionEventHandler(Iterations * NumProducers, _mru); _disruptor.HandleEventsWith(_eventHandler); _valueProducers = new ValueProducer[NumProducers]; _ringBuffer = _disruptor.GetRingBuffer; for (int i = 0; i < NumProducers; i++) { _valueProducers[i] = new ValueProducer(_testStartBarrier, _ringBuffer, Iterations); } }
public DiamondPath1P3CDisruptorWithAffinityPerfTest() : base(100 * Million) { _scheduler = new RoundRobinThreadAffinedTaskScheduler(4); _disruptor = new Disruptor<FizzBuzzEvent>(() => new FizzBuzzEvent(), Size, _scheduler); _mru = new ManualResetEvent(false); _fizzEventHandler = new FizzBuzzEventHandler(FizzBuzzStep.Fizz, Iterations, _mru); _buzzEventHandler = new FizzBuzzEventHandler(FizzBuzzStep.Buzz, Iterations, _mru); _fizzBuzzEventHandler = new FizzBuzzEventHandler(FizzBuzzStep.FizzBuzz, Iterations, _mru); _disruptor.HandleEventsWith(_fizzEventHandler, _buzzEventHandler) .Then(_fizzBuzzEventHandler); _ringBuffer = _disruptor.GetRingBuffer; }
public UrlCrawler(Uri startUrl) { DispatcherHelper.Initialize(); _urlStore = new ConcurrentDictionary<string, Uri>(); _queue = new ConcurrentQueue<Uri>(); _queue.Enqueue(startUrl); var urlDownloadHandlers = Enumerable.Range(0, 1000).Select(x => new UrlDownloadHandler()).ToArray(); var urlCrawlHandlers = Enumerable.Range(0, 10).Select(x => new UrlCrawlHandler()).ToArray(); var urlFinisherHandlers = Enumerable.Range(0, 10).Select(x => new UrlFinisherHandler(_urlStore, _queue, this)).ToArray(); Disruptor = new Disruptor<UrlEntry>(() => new UrlEntry(), new MultiThreadedLowContentionClaimStrategy(RingSize), new BlockingWaitStrategy(), TaskScheduler.Default); Disruptor.HandleEventsWith(urlDownloadHandlers).AsSequenceBarrier(); Disruptor.After(urlDownloadHandlers).HandleEventsWith(urlCrawlHandlers).AsSequenceBarrier(); Disruptor.After(urlCrawlHandlers).HandleEventsWith(urlFinisherHandlers).AsSequenceBarrier(); }
public TicketingApplication(ITicketCommandFactory ticketCommandFactory, IConcertService concertService, IApplicationServiceBus applicationServiceBus) { ApplicationServiceBus = applicationServiceBus; var inputBufferSize = 2 << 10; var claimStrategy = new SingleThreadedClaimStrategy(inputBufferSize); var waitStrategy = new SleepingWaitStrategy(); var commandHandlers = new CommandHandlerCollection(); RegisterCommandHandlers(concertService, commandHandlers); inputDisruptor = new Disruptor<CommandMessage>(() => new CommandMessage(), claimStrategy, waitStrategy, TaskScheduler.Default); inputDisruptor.HandleEventsWith(new CommandMessageHandler(commandHandlers)); // Publishers and translators to input buffer commandMessageTranslator = new CommandMessageTranslator(ticketCommandFactory, ApplicationServiceBus); }
public void Start() { requestDisrupter = new Disruptor<OutputQueueItem>(() => new OutputQueueItem(), (int)Math.Pow(16, 2), TaskScheduler.Default); requestDisrupter.HandleEventsWith(eventHandlers); requestRingBuffer = requestDisrupter.Start(); }
public void Start() { messageDisrupter = new Disruptor<ServerToClientMessage>(() => new ServerToClientMessage(), new SingleThreadedClaimStrategy(ringbufferSize), new SleepingWaitStrategy(), TaskScheduler.Default); messageDisrupter.HandleEventsWith(publisher); messageRingBuffer = messageDisrupter.Start(); logger.Info("Outgoing queue message queue started."); }