ReportGenerator converts coverage reports generated by coverlet, OpenCover, dotCover, Visual Studio, NCover, Cobertura, JaCoCo, Clover, gcov or lcov into human readable reports in various formats.
This is mainly done by avoiding creating additional StringBuilders and writing direct to the TextWriter where possible. Where StringBuilders are still needed, they're pooled and reused
Saves on the amount of allocated memory and time paused for GC.
I haven't measured a huge improvement in end to end report generation (maybe a second, but hard to say if that's within run to run variance), however reduction in allocations helps and this change does have measurable impacts when combined with my next PR.
Below are the perfview Results with my playground - built on top of the app from #691 with an an additional call to ReportGenerator.GenerateReport.
// Generate the html report with custom configuration for report generator.
var reportGeneratorConfig = new ReportConfigurationBuilder().Create(new Dictionary<string, string>() {
{ "targetdir", targetDir },
{ "sourcedirs", ".\\src" },
{ "reporttypes", "HtmlInline_AzurePipelines" }
});
var generator = new Generator() { };
var settings = new Settings() { };
stopwatch.Restart();
generator.GenerateReport(reportGeneratorConfig, settings, new RiskHotspotsAnalysisThresholds(), results);
Console.WriteLine($"ELAPSED: {stopwatch}");
This is mainly done by avoiding creating additional
StringBuilder
s and writing direct to theTextWriter
where possible. WhereStringBuilder
s are still needed, they're pooled and reusedSaves on the amount of allocated memory and time paused for GC.
I haven't measured a huge improvement in end to end report generation (maybe a second, but hard to say if that's within run to run variance), however reduction in allocations helps and this change does have measurable impacts when combined with my next PR.
Below are the perfview Results with my playground - built on top of the app from #691 with an an additional call to
ReportGenerator.GenerateReport
.Before
After