Пример #1
0
        private static void MakeStats(int threads, int count, long seed)
        {
            Console.WriteLine($"Collecting statistics from {count} random program executions (seed = {seed})");
            double step   = 0.05;
            double next   = step;
            var    runner = new ParallelRunner(seed);

            runner.Progress += (s, e) =>
            {
                if (runner.Percent > next)
                {
                    Console.Write($"{runner.Percent:P0}, ");
                    next += step;
                }
            };
            var sw    = Stopwatch.StartNew();
            var stats = runner.Run(threads, count);

            sw.Stop();
            Console.WriteLine();
            Console.WriteLine($"Completed in {sw.Elapsed.TotalSeconds} seconds");

            var fail = stats.FirstOrDefault(ri => !ri.Success);

            if (fail != null)
            {
                Console.WriteLine($"Error seed: {fail.Seed}");
                Console.WriteLine(fail.Output);
            }
            else
            {
                stats.Calculate();
                Console.WriteLine(stats);
            }
        }
Пример #2
0
        private static RuntimeStats MakeStats(int threads, int count, int timeout, long seed, ProgramOptions options, bool silent, bool evalTest, Uri runnerUri)
        {
            if (!silent)
            {
                Console.WriteLine($"Collecting statistics from {count} random program executions (seed = {seed})");
            }
            double step   = 0.05;
            double next   = step;
            var    runner = new ParallelRunner(seed, options, evalTest, runnerUri);

            if (!silent)
            {
                runner.Progress += (s, e) =>
                {
                    if (runner.Percent > next)
                    {
                        Console.Write($"{runner.Percent:P0}, ");
                        next += step;
                    }
                }
            }
            ;
            var          sw    = Stopwatch.StartNew();
            RuntimeStats stats = null;

            try
            {
                stats = runner.Run(threads, count, timeout);
            }
            catch (Exception e)
            {
                if (!silent)
                {
                    Console.WriteLine(e);
                }
            }
            sw.Stop();
            if (!silent)
            {
                Console.WriteLine();
                Console.WriteLine($"Completed in {sw.Elapsed.TotalSeconds} seconds");
            }
            var fail = stats?.FirstOrDefault(ri => !ri.Success);

            if (fail != null)
            {
                if (!silent)
                {
                    Console.WriteLine($"Error seed: {fail.Seed}");
                    Console.WriteLine(fail.Output);
                }
                stats = null;
            }
            else if (stats != null && stats.IsComplete)
            {
                stats.Calculate();
            }
            return(stats);
        }