-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support benchmarks with params (#18)
- Loading branch information
Showing
7 changed files
with
207 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Jobs; | ||
using System.Security.Cryptography; | ||
|
||
namespace Benchly.Benchmarks | ||
{ | ||
[BoxPlot(Title = "Box Plot")] | ||
[BarPlot(Title = "Bar Plot")] | ||
[Histogram] | ||
[Timeline] | ||
[MemoryDiagnoser, SimpleJob(RuntimeMoniker.Net60), SimpleJob(RuntimeMoniker.Net48)] | ||
public class Md5VsSha256Params | ||
{ | ||
private byte[] data; | ||
|
||
private readonly SHA256 sha256 = SHA256.Create(); | ||
private readonly MD5 md5 = MD5.Create(); | ||
|
||
[Params(128, 1024, 16384)] | ||
public int Size { get; set; } | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
data = new byte[Size]; | ||
new Random(42).NextBytes(data); | ||
} | ||
|
||
[Benchmark] | ||
public byte[] Sha256() => sha256.ComputeHash(data); | ||
|
||
[Benchmark] | ||
public byte[] Md5() => md5.ComputeHash(data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters