Пример #1
0
 public void InitializeThreadCount(int?loadingThreads)
 {
     lock (this)
     {
         _threadCountPreferred    = loadingThreads;
         _simultaneousFileOptions = (ImportResultsSimultaneousFileOptions)Settings.Default.ImportResultsSimultaneousFiles;
     }
 }
Пример #2
0
 public static int GetOptimalThreadCount(int?loadingThreads, int?fileCount,
                                         ImportResultsSimultaneousFileOptions simultaneousFileOptions)
 {
     if (ParallelEx.SINGLE_THREADED)
     {
         return(1); // Makes debugging easier.
     }
     return(GetOptimalThreadCount(loadingThreads, fileCount, Environment.ProcessorCount,
                                  simultaneousFileOptions));
 }
Пример #3
0
        public static int GetOptimalThreadCount(int?loadingThreads, int?fileCount, int processorCount, ImportResultsSimultaneousFileOptions simultaneousFileOptions)
        {
            if (!loadingThreads.HasValue)
            {
                switch (simultaneousFileOptions)
                {
                case ImportResultsSimultaneousFileOptions.one_at_a_time:
                    loadingThreads = 1;
                    break;

                case ImportResultsSimultaneousFileOptions.several:     // Several is 1/4 logical processors (i.e. 2 for an i7)
                    loadingThreads = Math.Max(2, processorCount / 4);  // Min of 2, because you really expect more than 1
                    break;

                case ImportResultsSimultaneousFileOptions.many:       // Many is 1/2 logical processors (i.e. 4 for an i7)
                    loadingThreads = Math.Max(2, processorCount / 2); // Min of 2, because you really expect more than 1
                    break;
                }
                loadingThreads = Math.Min(MAX_PARALLEL_LOAD_FILES, loadingThreads.Value);
                loadingThreads = GetBalancedThreadCount(loadingThreads.Value, fileCount);
            }

            return(loadingThreads.Value);
        }
Пример #4
0
        public static int GetOptimalThreadCount(int?loadingThreads, int?fileCount, int processorCount, ImportResultsSimultaneousFileOptions simultaneousFileOptions)
        {
            if (!loadingThreads.HasValue)
            {
                switch (simultaneousFileOptions)
                {
                case ImportResultsSimultaneousFileOptions.one_at_a_time:
                    loadingThreads = 1;
                    break;

                case ImportResultsSimultaneousFileOptions.several:     // Several is 1/4 logical processors (i.e. 2 for an i7)
                    loadingThreads = Math.Max(2, processorCount / 4);  // Min of 2, because you really expect more than 1
                    break;

                case ImportResultsSimultaneousFileOptions.many:       // Many is 1/2 logical processors (i.e. 4 for an i7)
                    loadingThreads = Math.Max(2, processorCount / 2); // Min of 2, because you really expect more than 1
                    break;
                }

                // On some systems we find that parallel performance suffers when not using ServerGC, as during SkylineTester runs
                var maxLoadThreads = GetMaxLoadThreadCount();
                loadingThreads = Math.Min(maxLoadThreads, loadingThreads.Value);
                loadingThreads = GetBalancedThreadCount(loadingThreads.Value, fileCount);
            }

            return(loadingThreads.Value);
        }