public void Run()
		{
			_bus.SubscribeHandler<LoadedRequest>(HandleLoadedRequest);
			_bus.SubscribeHandler<LoadedResponse>(HandleLoadedResponse);

			Stopwatch stopwatch = Stopwatch.StartNew();

			var endpoint = _bus.Endpoint;

			var request = new LoadedRequest(64);
			for (int index = 0; index < _messageCount; index++)
			{
				endpoint.Send(request);
			}

			bool requestComplete = _requestEvent.WaitOne(60.Seconds(), true);
			bool responseComplete = _responseEvent.WaitOne(60.Seconds(), true);

			stopwatch.Stop();

			Assert.IsTrue(requestComplete, "The requests did not complete");
			Assert.IsTrue(responseComplete, "The responses did not complete");

			Trace.WriteLine("Time to process " + _messageCount + " messages = " + stopwatch.ElapsedMilliseconds + "ms");
			Trace.WriteLine("Messages per second: " + _messageCount*1000/stopwatch.ElapsedMilliseconds);
		}
Exemple #2
0
        public void Run()
        {
            _bus.Subscribe <LoadedRequest>(HandleLoadedRequest);
            _bus.Subscribe <LoadedResponse>(HandleLoadedResponse);

            Stopwatch stopwatch = Stopwatch.StartNew();

            var endpoint = _bus.Endpoint;

            var request = new LoadedRequest(64);

            for (int index = 0; index < _messageCount; index++)
            {
                endpoint.Send(request);
            }

            bool requestComplete  = _requestEvent.WaitOne(60.Seconds(), true);
            bool responseComplete = _responseEvent.WaitOne(60.Seconds(), true);

            stopwatch.Stop();

            Assert.IsTrue(requestComplete, "The requests did not complete");
            Assert.IsTrue(responseComplete, "The responses did not complete");

            Trace.WriteLine("Time to process " + _messageCount + " messages = " + stopwatch.ElapsedMilliseconds + "ms");
            Trace.WriteLine("Messages per second: " + _messageCount * 1000 / stopwatch.ElapsedMilliseconds);
        }
		private void HandleLoadedRequest(LoadedRequest obj)
		{
			_bus.Publish(new LoadedResponse {Values = obj.Values});

			Interlocked.Increment(ref _requestCounter);
			if (_requestCounter == _messageCount)
				_requestEvent.Set();
		}
Exemple #4
0
        private void HandleLoadedRequest(LoadedRequest obj)
        {
            _bus.Publish(new LoadedResponse {
                Values = obj.Values
            });

            Interlocked.Increment(ref _requestCounter);
            if (_requestCounter == _messageCount)
            {
                _requestEvent.Set();
            }
        }