dotnet / dotnet/BenchmarkDotNet

Add WebPageExporter to export benchmark results as interactive HTML with PDF export capability

Open
#2,707 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
11.5k
Forks
1.1k
Avg merge
6d 11h
Merged PRs (30d)
12

Description

I'd like to suggest adding a `WebPageExporter` feature that would export benchmark results to an interactive HTML page with modern visualization capabilities.

**Motivation**

1. Presentation Enhancement: The current black and white CLI output doesn't present well in meetings. I've found myself manually converting benchmark results to more graphical formats for presentations. The `RPlotExporter` doesn't solve the problem because it forces me to install R and also the charts are static.
2. Data Exploration: An interactive page would allow users to investigate and explore benchmark data through modern charting libraries, enhancing the analysis experience.
3. Documentation: WebPage & PDF export capability would provide a clean way to include benchmark results in documentation and reports, making it easier to share performance insights.

**Proposed Solution**
Create a `WebPageExporter`class that:

1. Exports benchmark results to an index.html file
2. Utilizes a minimal React.js distribution for the UI framework
3. Incorporates Chart.js (or react-chartjs-2) for visualization
4. Include table
5. Includes PDF export functionality with configurable chart options
6. Include filter & sort functionality

`new WebPageExporter(exportPdf: new List { ChartType.Bar, ChartType.Pie })`
```

Example:
BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1905/22H2/2022Update/SunValley2)
Intel Core i7-10700K CPU 3.80GHz, 1 CPU, 16 logical and 8 physical cores
.NET SDK=7.0.302
[Host] : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2
DefaultJob : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2

| Method | Mean | Error | StdDev | Median | Ratio | RatioSD | Gen0 | Gen1 | Allocated | Alloc Ratio |
|------------------- |---------:|---------:|---------:|---------:|------:|--------:|----------:|---------:|----------:|------------:|
| StringConcatenate | 701.7 ns | 13.77 ns | 29.34 ns | 690.4 ns | 1.00 | 0.00 | 0.3433 | - | 2,160 B | 1.00 |
| StringBuilder_Ctor | 435.9 ns | 7.99 ns | 12.74 ns | 434.5 ns | 0.61 | 0.03 | 0.2446 | - | 1,536 B | 0.71 |
| StringBuilderA | 464.9 ns | 9.25 ns | 22.68 ns | 456.4 ns | 0.66 | 0.04 | 0.2518 | - | 1,584 B | 0.73 |
| StringBuilderB | 330.9 ns | 6.56 ns | 12.95 ns | 326.8 ns | 0.46 | 0.03 | 0.1783 | - | 1,120 B | 0.52 |
| StringInterpolate | 760.3 ns | 14.87 ns | 22.28 ns | 753.5 ns | 1.07 | 0.05 | 0.3433 | - | 2,160 B | 1.00 |
| FormattableStr1 | 729.7 ns | 14.06 ns | 29.31 ns | 721.8 ns | 1.03 | 0.06 | 0.4005 | 0.0029 | 2,520 B | 1.17 |
| FormattableStr2 | 738.7 ns | 14.32 ns | 30.51 ns | 736.9 ns | 1.05 | 0.07 | 0.3967 | 0.0029 | 2,496 B | 1.16 |
```
![Image](https://github.com/user-attachments/assets/fe27a9b1-b89d-4420-9815-7b6aa8ec47d0)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.