Esempio n. 1
0
        static void Main(string[] args)
        {
            int       i = 0;
            int       step = 1000;
            int       start, end;
            Stopwatch sw = new Stopwatch();

            sw.Start();
            while (i < 50000000 / step)
            {
                if (i == 0)
                {
                    start = 2;
                    end   = step;
                }
                else
                {
                    start = i * step + 1;
                    end   = (i + 1) * step;
                }
                PrimeCounter pc = new PrimeCounter(start, end, new Action <long>(SuccessCallBack));
                pc.StartCalculate();
                totalThreadCount++;
                i++;
            }
            while (totalFinishedCount < totalThreadCount)
            {
                Console.WriteLine("线程数 {0}|{1}", totalFinishedCount, totalThreadCount);
                Thread.Sleep(1000);
            }
            sw.Stop();
            Console.WriteLine("Result is {0} timeused {1}m{2}s{3}ms", totalCount, (int)sw.Elapsed.TotalMinutes, sw.Elapsed.Seconds, sw.Elapsed.Milliseconds);
        }
Esempio n. 2
0
 public UnitTest1(ITestOutputHelper logger)
 {
     Logger = logger;
     _sut   = new PrimeCounter(25);
 }