????????????????
???????????? ???????[ 2016/3/3 13:45:05 ] ??????????????? ???????
??????github???濴?????????BenchmarkDotNet????????£? ????????????????????????????????
??????????StopWatch?????BenchmarkDotNet???? http://www.cnblogs.com/rader/p/4920862.html
????????????????blog???????????????????????????????????????????????
?????????????????????????????????ò?????????????XUnit?????????????
????Nuget: https://www.nuget.org/packages/BenchmarkDotNet/
????Project Site: https://github.com/PerfDotNet/BenchmarkDotNet
???????BenchmarkDotNet
????PM> Install-Package BenchmarkDotNet
????????
public class Md5VsSha256
{
private const int N = 10000;
private readonly byte[] data;
private readonly SHA256 sha256 = SHA256.Create();
private readonly MD5 md5 = MD5.Create();
public Md5VsSha256()
{
data = new byte[N];
new Random(42).NextBytes(data);
}
[Benchmark]
public byte[] Sha256()
{
return sha256.ComputeHash(data);
}
[Benchmark]
public byte[] Md5()
{
return md5.ComputeHash(data);
}
}
????????
????var summary = BenchmarkRunner.Run<Md5VsSha256>();
???????
// * Summary *
BenchmarkDotNet=v0.9.1.0
OS=Microsoft Windows NT 6.1.7601 Service Pack 1
Processor=Intel(R) Core(TM) i5-4440 CPU @ 3.10GHz?? ProcessorCount=4
Frequency=3020400 ticks?? Resolution=331.0820 ns
HostCLR=MS.NET 4.0.30319.42000?? Arch=64-bit RELEASE [RyuJIT]
Type=BenchmarkTest Mode=Throughput
Method | Median | StdDev |
------- |----------- |---------- |
xxx | 58.4725 ns | 0.5935 ns |
// ***** BenchmarkRunner: End *****
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11