Skip to content

Commit be79d16

Browse files
authored
Merge pull request #508 from Shane32/benchmarks
Add benchmarking
2 parents f89aa90 + ffd49c3 commit be79d16

File tree

8 files changed

+81
-3
lines changed

8 files changed

+81
-3
lines changed

.github/workflows/wf-build-release-ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
2.0.x
2222
5.0.x
2323
6.0.x
24+
8.0.x
2425
2526
- name: Restore NuGet Packages
2627
run: dotnet restore
@@ -51,7 +52,8 @@ jobs:
5152
1.0.x
5253
2.0.x
5354
5.0.x
54-
6.0.x
55+
6.0.x
56+
8.0.x
5557
5658
- name: Run test .NET 3.5
5759
working-directory: QRCoderTests

.github/workflows/wf-build-release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
2.0.x
2323
5.0.x
2424
6.0.x
25+
8.0.x
2526
2627
- name: Restore NuGet Packages
2728
run: dotnet restore
@@ -52,7 +53,8 @@ jobs:
5253
1.0.x
5354
2.0.x
5455
5.0.x
55-
6.0.x
56+
6.0.x
57+
8.0.x
5658
5759
- name: Run test .NET 3.5
5860
working-directory: QRCoderTests

.github/workflows/wf-build-test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
2.0.x
2222
5.0.x
2323
6.0.x
24+
8.0.x
2425
2526
- name: Restore NuGet Packages
2627
run: dotnet restore
@@ -51,7 +52,8 @@ jobs:
5152
1.0.x
5253
2.0.x
5354
5.0.x
54-
6.0.x
55+
6.0.x
56+
8.0.x
5557
5658
- name: Run test .NET 3.5
5759
working-directory: QRCoderTests

QRCoder.sln

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QRCoder.Xaml", "QRCoder.Xam
1717
EndProject
1818
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QRCoderApiTests", "QRCoderApiTests\QRCoderApiTests.csproj", "{5FACE5F6-53C9-4B89-91D4-162677893574}"
1919
EndProject
20+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QRCoderBenchmarks", "QRCoderBenchmarks\QRCoderBenchmarks.csproj", "{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}"
21+
EndProject
2022
Global
2123
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2224
Debug|Any CPU = Debug|Any CPU
@@ -137,6 +139,22 @@ Global
137139
{5FACE5F6-53C9-4B89-91D4-162677893574}.Release|x64.Build.0 = Release|Any CPU
138140
{5FACE5F6-53C9-4B89-91D4-162677893574}.Release|x86.ActiveCfg = Release|Any CPU
139141
{5FACE5F6-53C9-4B89-91D4-162677893574}.Release|x86.Build.0 = Release|Any CPU
142+
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
143+
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Debug|Any CPU.Build.0 = Debug|Any CPU
144+
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Debug|ARM.ActiveCfg = Debug|Any CPU
145+
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Debug|ARM.Build.0 = Debug|Any CPU
146+
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Debug|x64.ActiveCfg = Debug|Any CPU
147+
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Debug|x64.Build.0 = Debug|Any CPU
148+
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Debug|x86.ActiveCfg = Debug|Any CPU
149+
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Debug|x86.Build.0 = Debug|Any CPU
150+
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Release|Any CPU.ActiveCfg = Release|Any CPU
151+
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Release|Any CPU.Build.0 = Release|Any CPU
152+
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Release|ARM.ActiveCfg = Release|Any CPU
153+
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Release|ARM.Build.0 = Release|Any CPU
154+
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Release|x64.ActiveCfg = Release|Any CPU
155+
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Release|x64.Build.0 = Release|Any CPU
156+
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Release|x86.ActiveCfg = Release|Any CPU
157+
{C33AB74A-2AB3-4BEA-A67F-EAB578E74E25}.Release|x86.Build.0 = Release|Any CPU
140158
EndGlobalSection
141159
GlobalSection(SolutionProperties) = preSolution
142160
HideSolutionNode = FALSE

QRCoderBenchmarks/Program.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
using BenchmarkDotNet.Running;
2+
3+
BenchmarkRunner.Run(typeof(Program).Assembly);

QRCoderBenchmarks/QRCodeGenerator.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using BenchmarkDotNet.Attributes;
2+
3+
namespace QRCoderBenchmarks;
4+
5+
[MemoryDiagnoser]
6+
public class QRCodeGenerator
7+
{
8+
[Benchmark]
9+
public void CreateQRCode()
10+
{
11+
var payload = new QRCoder.PayloadGenerator.Url("HTTP://WWW.GOOGLE.COM/");
12+
QRCoder.QRCodeGenerator qrGenerator = new QRCoder.QRCodeGenerator();
13+
_ = qrGenerator.CreateQrCode(payload, QRCoder.QRCodeGenerator.ECCLevel.L);
14+
}
15+
16+
[Benchmark]
17+
public void CreateQRCodeLong()
18+
{
19+
var payload = new QRCoder.PayloadGenerator.Url("https://github.com/codebude/QRCoder/blob/f89aa90081f369983a9ba114e49cc6ebf0b2a7b1/QRCoder/Framework4.0Methods/Stream4Methods.cs");
20+
QRCoder.QRCodeGenerator qrGenerator = new QRCoder.QRCodeGenerator();
21+
_ = qrGenerator.CreateQrCode(payload, QRCoder.QRCodeGenerator.ECCLevel.H);
22+
}
23+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<ProjectReference Include="..\QRCoder\QRCoder.csproj" />
16+
</ItemGroup>
17+
18+
</Project>

QRCoderTests/QRGeneratorTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ public void can_encode_alphanumeric()
113113
result.ShouldBe("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111010111011111110000000010000010001100100000100000000101110101101001011101000000001011101011001010111010000000010111010100100101110100000000100000100111101000001000000001111111010101011111110000000000000000000110000000000000000111100101111110011101000000000111100010011110001110000000000100010100100000001000000000011110011111001110011000000001111101110101001000000000000000000000111100100100100000000111111100001100100110000000001000001000100001111110000000010111010010011111010100000000101110101111001011110000000001011101010101011000000000000010000010111001000010000000000111111101010010010010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
114114
}
115115

116+
[Fact]
117+
[Category("QRGenerator/TextEncoding")]
118+
public void can_encode_byte_long()
119+
{
120+
var gen = new QRCodeGenerator();
121+
var qrData = gen.CreateQrCode("https://github.com/codebude/QRCoder/blob/f89aa90081f369983a9ba114e49cc6ebf0b2a7b1/QRCoder/Framework4.0Methods/Stream4Methods.cs", QRCodeGenerator.ECCLevel.H);
122+
var result = string.Join("", qrData.ModuleMatrix.Select(x => x.ToBitString()).ToArray());
123+
result.ShouldBe("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111110111011110110000101001110011101111011110001011011111110000000010000010111110111110001010010001100010100000011000011010000010000000010111010110010100110110000100110001010110100101010111010111010000000010111010000110010111011000101111110011010101000100101010111010000000010111010011010111000011000101111100001101111110001110010111010000000010000010110101101010101100011000100100100001011101100010000010000000011111110101010101010101010101010101010101010101010101011111110000000000000000111011011010010111001000100010111011010101000000000000000000000111010111110001111111100111111110110000111011110011111001110000000011111101111010101011111100011110101010001011000111000110100000000000000101111000110111101010010011011000010000110010110101000000110000000000000001111100010111100110100010100011010111100000001000100010000000000101010011011100110011111101000111110001100011111011011011110000000010010001110011110000101111001100100011001111110010010011010100000000001010011010001011011011010111011001110110000001001100101011110000000010110000111100111100010110011101110000001101111001000010110010000000010101010100011010111011110111010010100010100000110111111011010000000000110101111110101110100001101100010101110110010111000011010000000000001011111111001010110101000111001001011011000101011111101010110000000000010000000110100110010011100110100000100110111101001011110000000000010101110011111100011001000110101101111001011000011001001001100000000000100000101111001101001100001000010110010111000001000010010100000000010000011000010110111001110111011010010101000111011110100111110000000001100000100110001100100010101111011011100010110101000010000010000000000001111101011110111110100010100101010101111000010000000011110000000011010100010000111011000110000110001011000111110011010011100100000000010010011011110011110011001101110011001110001111110000000011010000000011101000110001100001110010010001011000000010101101110010110100000000010111111101100100010001000111111100111011101000010101111101000000000011001000110101111011001011001000101101011111100001101000100000000000010001010100000111101011101111010101010000000011110011010110110000000010111000100001011000010010011000100000100110101000011000100100000000000001111101111110100000010101111111100001001001110001111111100000000010111001011011001100001101010001000100111111100101011011000000000000000000011111101001100110000110100010001111001111101100111010110000000010101101101010110010011111101010000100100010000110001011010000000000010100011111001110010000010000111111110110001110111111011111010000000000001000000111110111001100111011011010100110100111011110010000000000000110111001011011100010111100000000010010011111010100110111110000000001110000110101101001100001001000111010011100110001111001100110000000001100011100110101100100101001010001100110101000111111101111000000000011101100100001000100011101010100111110101110010101001001010100000000011111110000111010111100001011011101000110100100101000101001010000000010111101100010010110000011101011011101101101101100001011000110000000010101111001111111101011010100000001000100101001010110110101000000000000011101100001001011001110010110111100101110010100000011001100000000010001111010011100000100100110111011011010111011010111110001110000000010000001111101010111111110001110110001011111101110000100000110000000000100010110000000101000111001011000011100011001011111011111110000000010110101101100011101011100001111101011111111000110010000011000000000000111111100010001000110100000001101111110101011011110011010110000000011101000111010011011110100001010110011111101010001001000000010000000011110011110100001110111110011111101110100001001111011111101110000000000000000100110000001011111101000100101001101100110001000110100000000011111110011101111000110110011010110001110011111101111010111110000000010000010010101100101110011001000111101111010111001011000100110000000010111010100001010110001101111111101101000111010111111111101000000000010111010101001111101101011110000100011100011110011011111101010000000010111010100101010001000010100001001101000100001110100010001010000000010000010001010111111111001100110111100101011111000010110000010000000011111110001011000110010001101010000101110110000110101000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
124+
}
125+
116126
[Fact]
117127
[Category("QRGenerator/TextEncoding")]
118128
public void can_encode_byte()

0 commit comments

Comments
 (0)