Пример #1
0
        private void MonteCarloSim(int requestIterations, int divisor)
        {
            var global = new IterationResults();

            for (int i = 0; i < 100; i++)
            {
                var result = IterativeTest(requestIterations, divisor);
                global.MissRatio = (global.MissRatio + result.MissRatio) / 2;
                global.Elapsed   = (global.Elapsed + result.Elapsed) / 2;

                if (i == 0 || result.MissRatio > global.MaxMissRatio)
                {
                    global.MaxMissRatio = result.MissRatio;
                }

                if (i == 0 || result.MissRatio < global.MinMissRatio)
                {
                    global.MinMissRatio = result.MissRatio;
                }

                if (i == 0 || result.Elapsed > global.MaxElapsed)
                {
                    global.MaxElapsed = result.Elapsed;
                }

                if (i == 0 || result.Elapsed < global.MinElapsed)
                {
                    global.MinElapsed = result.Elapsed;
                }
            }

            int capacity = (divisor == 0) ? 0 : (requestIterations / divisor);

            Console.WriteLine(
                "Iterations : {0:00000}, Capacity: {1:00000} (1/{2:00}), Hit ratio: {3:00.00}% ({4:00.00}% - {5:00.00}%), Elapsed: {6:0000.00}ms ({7:0000.00}ms - {8:0000.00}ms)",
                requestIterations, capacity, divisor, 100 - global.MissRatio, 100 - global.MaxMissRatio, 100 - global.MinMissRatio,
                global.Elapsed, global.MinElapsed, global.MaxElapsed);
        }
Пример #2
0
        private void MonteCarloSim(int requestIterations, int divisor)
        {
            var global = new IterationResults();

            for (int i = 0; i < 100; i++)
            {
                var result = IterativeTest(requestIterations, divisor);
                global.MissRatio = (global.MissRatio + result.MissRatio) / 2;
                global.Elapsed = (global.Elapsed + result.Elapsed) / 2;

                if (i == 0 || result.MissRatio > global.MaxMissRatio)
                {
                    global.MaxMissRatio = result.MissRatio;
                }

                if (i == 0 || result.MissRatio < global.MinMissRatio)
                {
                    global.MinMissRatio = result.MissRatio;
                }

                if (i == 0 || result.Elapsed > global.MaxElapsed)
                {
                    global.MaxElapsed = result.Elapsed;
                }

                if (i == 0 || result.Elapsed < global.MinElapsed)
                {
                    global.MinElapsed = result.Elapsed;
                }
            }

            int capacity = (divisor == 0) ? 0 : (requestIterations / divisor);

            Console.WriteLine(
                    "Iterations : {0:00000}, Capacity: {1:00000} (1/{2:00}), Hit ratio: {3:00.00}% ({4:00.00}% - {5:00.00}%), Elapsed: {6:0000.00}ms ({7:0000.00}ms - {8:0000.00}ms)",
                    requestIterations, capacity, divisor, 100 - global.MissRatio, 100 - global.MaxMissRatio, 100 - global.MinMissRatio,
                    global.Elapsed, global.MinElapsed, global.MaxElapsed);
        }