Skip to content

Commit

Permalink
Add benchmark project
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane32 committed Apr 28, 2024
1 parent f89aa90 commit d2a0c4c
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/wf-build-release-ci.yml
Expand Up @@ -21,6 +21,7 @@ jobs:
2.0.x
5.0.x
6.0.x
8.0.x
- name: Restore NuGet Packages
run: dotnet restore
Expand Down Expand Up @@ -51,7 +52,8 @@ jobs:
1.0.x
2.0.x
5.0.x
6.0.x
6.0.x
8.0.x
- name: Run test .NET 3.5
working-directory: QRCoderTests
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/wf-build-release.yml
Expand Up @@ -22,6 +22,7 @@ jobs:
2.0.x
5.0.x
6.0.x
8.0.x
- name: Restore NuGet Packages
run: dotnet restore
Expand Down Expand Up @@ -52,7 +53,8 @@ jobs:
1.0.x
2.0.x
5.0.x
6.0.x
6.0.x
8.0.x
- name: Run test .NET 3.5
working-directory: QRCoderTests
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/wf-build-test.yml
Expand Up @@ -21,6 +21,7 @@ jobs:
2.0.x
5.0.x
6.0.x
8.0.x
- name: Restore NuGet Packages
run: dotnet restore
Expand Down Expand Up @@ -51,7 +52,8 @@ jobs:
1.0.x
2.0.x
5.0.x
6.0.x
6.0.x
8.0.x
- name: Run test .NET 3.5
working-directory: QRCoderTests
Expand Down
18 changes: 18 additions & 0 deletions QRCoder.sln
Expand Up @@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QRCoder.Xaml", "QRCoder.Xam
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QRCoderApiTests", "QRCoderApiTests\QRCoderApiTests.csproj", "{5FACE5F6-53C9-4B89-91D4-162677893574}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QRCoderBenchmarks", "QRCoderBenchmarks\QRCoderBenchmarks.csproj", "{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -137,6 +139,22 @@ Global
{5FACE5F6-53C9-4B89-91D4-162677893574}.Release|x64.Build.0 = Release|Any CPU
{5FACE5F6-53C9-4B89-91D4-162677893574}.Release|x86.ActiveCfg = Release|Any CPU
{5FACE5F6-53C9-4B89-91D4-162677893574}.Release|x86.Build.0 = Release|Any CPU
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Debug|ARM.ActiveCfg = Debug|Any CPU
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Debug|ARM.Build.0 = Debug|Any CPU
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Debug|x64.ActiveCfg = Debug|Any CPU
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Debug|x64.Build.0 = Debug|Any CPU
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Debug|x86.ActiveCfg = Debug|Any CPU
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Debug|x86.Build.0 = Debug|Any CPU
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Release|Any CPU.Build.0 = Release|Any CPU
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Release|ARM.ActiveCfg = Release|Any CPU
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Release|ARM.Build.0 = Release|Any CPU
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Release|x64.ActiveCfg = Release|Any CPU
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Release|x64.Build.0 = Release|Any CPU
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Release|x86.ActiveCfg = Release|Any CPU
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 4 additions & 0 deletions QRCoderBenchmarks/Program.cs
@@ -0,0 +1,4 @@
using BenchmarkDotNet.Running;

//var summary =
BenchmarkRunner.Run(typeof(Program).Assembly);
23 changes: 23 additions & 0 deletions QRCoderBenchmarks/QRCodeGenerator.cs
@@ -0,0 +1,23 @@
using BenchmarkDotNet.Attributes;

namespace QRCoderBenchmarks;

[MemoryDiagnoser]
public class QRCodeGenerator
{
[Benchmark]
public void CreateQRCode()
{
var payload = new QRCoder.PayloadGenerator.Url("HTTP://WWW.GOOGLE.COM/");
QRCoder.QRCodeGenerator qrGenerator = new QRCoder.QRCodeGenerator();
_ = qrGenerator.CreateQrCode(payload, QRCoder.QRCodeGenerator.ECCLevel.L);
}

[Benchmark]
public void CreateQRCodeLong()
{
var payload = new QRCoder.PayloadGenerator.Url("https://github.com/codebude/QRCoder/blob/f89aa90081f369983a9ba114e49cc6ebf0b2a7b1/QRCoder/Framework4.0Methods/Stream4Methods.cs");
QRCoder.QRCodeGenerator qrGenerator = new QRCoder.QRCodeGenerator();
_ = qrGenerator.CreateQrCode(payload, QRCoder.QRCodeGenerator.ECCLevel.H);
}
}
18 changes: 18 additions & 0 deletions QRCoderBenchmarks/QRCoderBenchmarks.csproj
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\QRCoder\QRCoder.csproj" />
</ItemGroup>

</Project>

0 comments on commit d2a0c4c

Please sign in to comment.