Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add benchmarking #508

Merged
merged 2 commits into from Apr 29, 2024
Merged

Add benchmarking #508

merged 2 commits into from Apr 29, 2024

Conversation

Shane32
Copy link
Contributor

@Shane32 Shane32 commented Apr 28, 2024

Summary

This PR adds a benchmarking project to the solution so that performance gains during optimizations may be analyzed.

What existing problem does the pull request solve?

It is difficult to quantify the gains from applying performance optimizations without benchmarks.

Sample Output

BenchmarkDotNet v0.13.12, Windows 10 (10.0.19045.4291/22H2/2022Update)
13th Gen Intel Core i9-13900K, 1 CPU, 32 logical and 24 physical cores
.NET SDK 8.0.202
  [Host]     : .NET 8.0.3 (8.0.324.11423), X64 RyuJIT AVX2
  DefaultJob : .NET 8.0.3 (8.0.324.11423), X64 RyuJIT AVX2
Method Mean Error StdDev Gen0 Gen1 Allocated
CreateQRCode 245.4 us 4.88 us 5.80 us 17.0898 0.2441 317.99 KB
CreateQRCodeLong 7,531.1 us 34.13 us 31.92 us 265.6250 15.6250 4920.13 KB

Legend

Term Description
Mean Arithmetic mean of all measurements
Error Half of 99.9% confidence interval
StdDev Standard deviation of all measurements
Gen0 GC Generation 0 collects per 1000 operations
Gen1 GC Generation 1 collects per 1000 operations
Allocated Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)
1 us 1 Microsecond (0.000001 sec)

Observations

Creating the QR code uses a lot of RAM, which triggers garbage collections more frequently. Minimizing the number of garbage collections through a more efficient QR code algorithm can significantly enhance the stability and performance of an ASP.NET Core application. By optimizing the QR code generation process, the application can manage memory better, reduce latency, and handle higher user loads with greater reliability, ultimately improving user experience and application scalability.

Similar benefits would be realized for other targets, such as blazor/webassembly.

Notes

This project targets .NET 8 so that any performance benefits are measured for a developer targeting the latest version of .NET. The compilation targets for the main project have not changed; however, the .NET 8 SDK was added to the CI workflows so that building the solution does not cause a build error.

@codebude
Copy link
Owner

Hi @Shane32 , you rock it! That's another great PR. Thanks for your support in this project.

@codebude codebude merged commit be79d16 into codebude:master Apr 29, 2024
3 checks passed
@Shane32 Shane32 deleted the benchmarks branch April 29, 2024 19:44
@codebude
Copy link
Owner

Hi @Shane32 seems like this PR broke the CI scripts. Can you have a look?
https://github.com/codebude/QRCoder/actions/runs/8884442673/job/24413893321

Run dotnet restore
  dotnet restore
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
  env:
    GH_PKG_SEC: ***
    DOTNET_ROOT: C:\Program Files\dotnet
  Determining projects to restore...
Error: C:\Program Files\dotnet\sdk\7.0.[4](https://github.com/codebude/QRCoder/actions/runs/8884442673/job/24413893321#step:4:4)08\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(160,[5](https://github.com/codebude/QRCoder/actions/runs/8884442673/job/24413893321#step:4:5)): error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0.  Either target .NET [7](https://github.com/codebude/QRCoder/actions/runs/8884442673/job/24413893321#step:4:8).0 or lower, or use a version of the .NET SDK that supports .NET [8](https://github.com/codebude/QRCoder/actions/runs/8884442673/job/24413893321#step:4:9).0. Download the .NET SDK from https://aka.ms/dotnet/download [D:\a\QRCoder\QRCoder\QRCoderBenchmarks\QRCoderBenchmarks.csproj]
Error: Process completed with exit code 1.

@Shane32 Shane32 mentioned this pull request Apr 30, 2024
@Shane32
Copy link
Contributor Author

Shane32 commented Apr 30, 2024

No problem. My mistake; I added the .NET 8 SDK twice instead of three times to those scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants