public static string ExecuteAndRenderWithDefaults(string outputPath = null, BenchmarkOptions options = null)
        {
            string templatePath = Path.Combine(Environment.CurrentDirectory, HtmlOutputRenderer.DefaultReportName);

            if (String.IsNullOrWhiteSpace(outputPath))
            {
                outputPath = Path.Combine(Path.GetTempPath(), HtmlOutputRenderer.DefaultReportName);
            }

            var engine = new BenchmarkEngine(options ?? new BenchmarkOptions {
                SearchMethod = BencharkSearchMethod.Convention
            },
                                             new Assembly[] { Assembly.GetCallingAssembly() });

            var renderer = new HtmlOutputRenderer();

            renderer.TemplatePath = templatePath;
            renderer.Statistics   = new BasicStatistics()
            {
                CutTails = true
            };
            renderer.RenderTo(outputPath, engine.Execute());

            return(outputPath);
        }
示例#2
0
        private byte[] Render <T>()
        {
            // Just one repetition, we do not really care about results
            var engine = CreateEngine <T>(new BenchmarkOptions()
            {
                Repetitions = 1
            });
            var renderer = new HtmlOutputRenderer
            {
                Statistics   = new BasicStatistics(),
                TemplatePath = Path.Combine(Environment.CurrentDirectory, HtmlOutputRenderer.DefaultReportName)
            };

            var output = renderer.Render(engine.Execute());

            // First simple check to be sure we actually have something to test
            Assert.IsTrue(output != null && output.Length > 0);

            return(output);
        }