|
| 1 | +using BenchmarkDotNet.Attributes; |
| 2 | +using QRCoder; |
| 3 | + |
| 4 | +namespace QRCoderBenchmarks; |
| 5 | + |
| 6 | +[MemoryDiagnoser] |
| 7 | +public class PngByteQRCodeBenchmark |
| 8 | +{ |
| 9 | + private readonly Dictionary<string, QRCodeData> _samples; |
| 10 | + |
| 11 | + public PngByteQRCodeBenchmark() |
| 12 | + { |
| 13 | + var eccLvl = QRCoder.QRCodeGenerator.ECCLevel.L; |
| 14 | + _samples = new Dictionary<string, QRCodeData>() |
| 15 | + { |
| 16 | + { "small", QRCoder.QRCodeGenerator.GenerateQrCode("ABCD", eccLvl) }, |
| 17 | + { "medium", QRCoder.QRCodeGenerator.GenerateQrCode("https://github.com/codebude/QRCoder/blob/f89aa90081f369983a9ba114e49cc6ebf0b2a7b1/QRCoder/Framework4.0Methods/Stream4Methods.cs", eccLvl) }, |
| 18 | + { "big", QRCoder.QRCodeGenerator.GenerateQrCode( new string('a', 2600), eccLvl) } |
| 19 | + }; |
| 20 | + } |
| 21 | + |
| 22 | + |
| 23 | + [Benchmark] |
| 24 | + public void RenderPngByteQRCodeSmall() |
| 25 | + { |
| 26 | + var qrCode = new PngByteQRCode(_samples["small"]); |
| 27 | + _ = qrCode.GetGraphic(10); |
| 28 | + } |
| 29 | + |
| 30 | + [Benchmark] |
| 31 | + public void RenderPngByteQRCodeMedium() |
| 32 | + { |
| 33 | + var qrCode = new PngByteQRCode(_samples["medium"]); |
| 34 | + _ = qrCode.GetGraphic(10); |
| 35 | + } |
| 36 | + |
| 37 | + [Benchmark] |
| 38 | + public void RenderPngByteQRCodeBig() |
| 39 | + { |
| 40 | + var qrCode = new PngByteQRCode(_samples["big"]); |
| 41 | + _ = qrCode.GetGraphic(10); |
| 42 | + } |
| 43 | + |
| 44 | + [Benchmark] |
| 45 | + public void RenderPngByteQRCodeHuge() |
| 46 | + { |
| 47 | + var qrCode = new PngByteQRCode(_samples["big"]); |
| 48 | + _ = qrCode.GetGraphic(50); |
| 49 | + } |
| 50 | +} |
0 commit comments