Beispiel #1
0
        static string Run(int threads, TestCaseEnvironmentGeneric testCaseEnvironment, int numberOfJobs)
        {
            Console.WriteLine($"Starting run for {testCaseEnvironment.CachingStrategyName}");
            var resultsStorage = new List <ResponseContainer>();

            for (var i = 0; i < numberOfJobs; ++i)
            {
                resultsStorage.Add(new ResponseContainer());
            }

            var stopwatch = new Stopwatch();

            stopwatch.Start();
            JobRunner.RunXTimes(testCaseEnvironment.DoUnitOfWork, resultsStorage, threads);
            stopwatch.Stop();


            var(variance, standardDeviation, min, max, averageTicks, ticks) = CalculateVariance(resultsStorage);
            var ticksText = "";// string.Join(',', ticks);

            var times               = resultsStorage.Select(st => st.RunTime).ToArray();
            var timeOfWork          = times.Select(t => t.TotalMilliseconds).Sum();
            var averageMs           = timeOfWork / numberOfJobs;
            var cacheHitsCount      = resultsStorage.Where(r => r.Result.CacheHit).Count();
            var obtainedValuesCount = resultsStorage.Where(r => r.Result.ObtainedValue).Count();
            var waitingTime         = resultsStorage.Select(r => r.Result.MillisecondsWaiting).Sum();
            var badCount            = resultsStorage.Where(r => string.IsNullOrWhiteSpace(r.Result.Address)).Count();

            var summary = $"{testCaseEnvironment.CachingStrategyName} run: {stopwatch.ElapsedMilliseconds}ms, worked: {timeOfWork}ms, average job: {averageMs}ms, Cached#:{cacheHitsCount}, Obtains#:{obtainedValuesCount}, Bad#:{badCount}, Waiting[ms]:{waitingTime}, Min:{min}, Max:{max}, AvgTicks:{averageTicks} Variance:{variance}, StdDev:{standardDeviation}\n{ticksText}";

            return(summary);
        }
Beispiel #2
0
        public static string RunTest(int seed, int numberOfJobs, int threads, int maxLengthOfNsLookup, int staticLengthOfAQueryWork, int numberOfIps, int method)
        {
            var testEnvironment = TestCaseEnvironmentGeneric.Create(seed, maxLengthOfNsLookup, staticLengthOfAQueryWork, numberOfIps, method);
            var resultOfTest    = Run(threads, testEnvironment, numberOfJobs);

            return($"Jobs: {numberOfJobs}, Threads: {threads}, OperationMaxT:{maxLengthOfNsLookup}, StaticOpCost:{staticLengthOfAQueryWork}, CachingItems:{numberOfIps} - {resultOfTest}");
        }