예제 #1
0
        public void CanMeasureSingleMethod()
        {
            var result = BenchmarkEngine.ExecuteSingle(typeof(SingleBenchmark));

            Assert.IsTrue(result >= TimeSpan.FromMilliseconds(1), "Average execution time cannot be smaller than minimum expected value.");
            Assert.IsTrue(result <= TimeSpan.FromMilliseconds(10), "Average execution time cannot be too much higher than maximum expected value.");
        }
예제 #2
0
        public void CanDiscoverTypesInAssembly()
        {
            var engine = new BenchmarkEngine(new BenchmarkOptions()
            {
                Repetitions = 1
            }, new Assembly[] { GetType().Assembly });
            var results = engine.Execute();

            Assert.AreEqual(3, results.Count(), "This test library contains three valid benchmark classes.");
        }
예제 #3
0
        public void CanQuicklyCreateReport()
        {
            var tempPath = BenchmarkEngine.ExecuteAndRenderWithDefaults(null, new BenchmarkOptions()
            {
                Repetitions = 1
            });

            Assert.IsTrue(File.Exists(tempPath));

            File.Delete(tempPath);
        }
예제 #4
0
        static void Main()
        {
            Console.WriteLine("Performing benchmarks...");
            //Process.Start(BenchmarkEngine.ExecuteAndRenderWithDefaults(null, new BenchmarkOptions { Repetitions = 10 }));

            var engine = new BenchmarkEngine(new BenchmarkOptions {
                Repetitions = 10
            }, new Assembly[] { typeof(Program).Assembly });
            var renderer = new ExcelOutputRenderer();

            string outputPath = Path.Combine(Path.GetTempPath(), DateTime.Now.Ticks.ToString() + ".xlsx");

            renderer.RenderTo(outputPath, engine.Execute());

            Process.Start(outputPath);
        }