Ejemplo n.º 1
0
        internal void MessagingPerformanceTest()
        {
            // Arrange
            var receiver = new MockComponent(this.container);

            receiver.RegisterHandler <int>(receiver.OnMessage);

            PerformanceHarness.Test(() =>
            {
                for (var i = 0; i < 1000000; i++)
                {
                    receiver.Endpoint.SendAsync(i);
                    receiver.Endpoint.SendAsync(i);
                }

                while (receiver.ProcessedCount < 2000000)
                {
                    // Wait
                }
            },
                                    1,
                                    1,
                                    this.Output);

            this.Output.WriteLine(receiver.Messages.Count.ToString());

            // ~1350 ms for 1000000 messages with Task<bool> being returned by handler
            // ~1250 ms for 1000000 messages with bool being returned by handler
            //  ~850 ms for 1000000 messages (19/7/2020)

            // Assert
            Assert.Equal(0, receiver.InputCount);
            Assert.Equal(2000000, receiver.ProcessedCount);
        }
Ejemplo n.º 2
0
        internal void Test_CanPerformTest_ReturnsReasonableTimeSpan()
        {
            // Arrange
            var numbersList = new List <int> {
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9
            };

            // Act
            var result = PerformanceHarness.Test(() => numbersList.ToArray(), 3, 1000000);

            // Assert
            Assert.True(result.Milliseconds < 300);
        }