Esempio n. 1
0
        public void AllResultsHaveName()
        {
            var benchmarkResults = CreateEngine <AleatoryBenchmark>(new BenchmarkOptions()
            {
                Repetitions = 1
            }).Execute();

            var statisticCalculator = new BasicStatistics();
            var statisticResults    = statisticCalculator.Calculate(benchmarkResults.Single().Methods.Single());

            Assert.AreEqual(statisticResults.Count, statisticCalculator.GetHeaders().Count());
        }
Esempio n. 2
0
        public void ValuesHaveRequiredOrder()
        {
            // We need EXACTLY this order because of how HtmlOutputRenderer and its HTML template files
            // are implemented. If things will change there (with more robust code) then this test may
            // be simplified.
            // Note that with a small number of repetitions this check may fail because of "random" function call overhead, if
            // this test fails on some environment you may need to increase this number (I keep it low just to make test faster).
            var benchmarkResults = CreateEngine <AleatoryBenchmark>(new BenchmarkOptions()
            {
                Repetitions = 10
            }).Execute();

            var statisticCalculator = new BasicStatistics();
            var statisticResults    = statisticCalculator.Calculate(benchmarkResults.Single().Methods.Single());

            var distribution = statisticCalculator.GetHeaders().Select(x => (TimeSpan)statisticResults[x]).ToArray();

            for (int i = 1; i < distribution.Length; ++i)
            {
                Assert.IsTrue(distribution[i] > distribution[i - 1],
                              String.Format("Item #{0} has value {1} but it should be greater than item #{2} (with value {3}.", i, distribution[i], i - 1, distribution[i - 1]));
            }
        }