Exemple #1
0
        public void ConfigureThreadPoolWithoutMultiplier()
        {
            var valuesSet = new PerformanceConfiguration
            {
                UseCoreMultiplier          = false,
                MinimumWorkerThreads       = 40,
                MinimumIoCompletionThreads = 20,
                MaximumWorkerThreads       = 80,
                MaximumIoCompletionThreads = 60
            };

            PerformanceManager.ConfigureThreadPool(valuesSet);

            ThreadPool.GetMinThreads(out var minimumWorkerThreads, out var minimumCompletionThreads);
            ThreadPool.GetMaxThreads(out var maximumWorkerThreads, out var maximumCompletionThreads);

            Assert.IsTrue(valuesSet.MaximumIoCompletionThreads.Value == maximumCompletionThreads, "Not set maximum completion not expected");
            Assert.IsTrue(valuesSet.MaximumWorkerThreads.Value == maximumWorkerThreads, "Not set maximum worker not expected");
            Assert.IsTrue(valuesSet.MinimumIoCompletionThreads.Value == minimumCompletionThreads, "Not set minimum completion not expected");
            Assert.IsTrue(valuesSet.MinimumWorkerThreads.Value == minimumWorkerThreads, "Not set minimum worker not expected");
        }
Exemple #2
0
        public void ConfigureThreadPoolWitMultiplier()
        {
            var valuesSet = new PerformanceConfiguration
            {
                UseCoreMultiplier          = true,
                MinimumWorkerThreads       = 40,
                MinimumIoCompletionThreads = 20,
                MaximumWorkerThreads       = 80,
                MaximumIoCompletionThreads = 60
            };

            PerformanceManager.ConfigureThreadPool(valuesSet);

            ThreadPool.GetMinThreads(out var minimumWorkerThreads, out var minimumCompletionThreads);
            ThreadPool.GetMaxThreads(out var maximumWorkerThreads, out var maximumCompletionThreads);

            Task.Delay(1000).GetAwaiter().GetResult();

            Assert.IsTrue((valuesSet.MaximumIoCompletionThreads.Value * Environment.ProcessorCount) == maximumCompletionThreads, "Not set maximum completion not expected");
            Assert.IsTrue((valuesSet.MaximumWorkerThreads.Value * Environment.ProcessorCount) == maximumWorkerThreads, "Not set maximum worker not expected");
            Assert.IsTrue((valuesSet.MinimumIoCompletionThreads.Value * Environment.ProcessorCount) == minimumCompletionThreads, "Not set minimum completion not expected");
            Assert.IsTrue((valuesSet.MinimumWorkerThreads.Value * Environment.ProcessorCount) == minimumWorkerThreads, "Not set minimum worker not expected");
        }