Example #1
0
 public void Take(int count)
 {
     if (_testResults.IsHighest(count))
     {
         _testResults.SetHighest(count);
     }
 }
        public void TestThroughput()
        {
            Init(ThroughputMailboxSize);

            var testResults = new TestResults(ThroughputMailboxSize);
            var countTaker  = World.ActorFor <ICountTaker>(
                Definition.Has <ThroughputCountTakerActor>(
                    Definition.Parameters(testResults), "testRingMailbox", "countTaker-2"));

            testResults.SetMaximum(ThroughputWarmUpCount);

            for (var count = 1; count <= ThroughputWarmUpCount; ++count)
            {
                countTaker.Take(count);
            }

            while (testResults.GetHighest() < ThroughputWarmUpCount)
            {
            }

            testResults.SetHighest(0);
            testResults.SetMaximum(ThroughputMaxCount);

            var startTime = DateTime.UtcNow;

            for (int count = 1; count <= ThroughputMaxCount; ++count)
            {
                countTaker.Take(count);
            }

            while (testResults.GetHighest() < ThroughputMaxCount)
            {
            }

            var timeSpent = DateTime.UtcNow - startTime;

            Console.WriteLine("Ms: " + timeSpent.TotalMilliseconds + " FOR " + ThroughputMaxCount + " MESSAGES IS " + (ThroughputMaxCount / timeSpent.TotalSeconds) + " PER SECOND");

            Assert.Equal(ThroughputMaxCount, testResults.GetHighest());
        }