-
-
Notifications
You must be signed in to change notification settings - Fork 940
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fdd1130
commit 4ba591e
Showing
5 changed files
with
165 additions
and
11 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
src/Renci.SshNet.Benchmarks/Common/HostKeyEventArgsBenchmarks.cs
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,66 @@ | ||
using BenchmarkDotNet.Attributes; | ||
|
||
using Renci.SshNet.Benchmarks.Security.Cryptography.Ciphers; | ||
using Renci.SshNet.Common; | ||
using Renci.SshNet.Security; | ||
|
||
namespace Renci.SshNet.Benchmarks.Common | ||
{ | ||
[MemoryDiagnoser] | ||
[ShortRunJob] | ||
public class HostKeyEventArgsBenchmarks | ||
{ | ||
private readonly KeyHostAlgorithm _keyHostAlgorithm; | ||
|
||
public HostKeyEventArgsBenchmarks() | ||
{ | ||
_keyHostAlgorithm = GetKeyHostAlgorithm(); | ||
} | ||
private static KeyHostAlgorithm GetKeyHostAlgorithm() | ||
{ | ||
using (var s = typeof(RsaCipherBenchmarks).Assembly.GetManifestResourceStream("Renci.SshNet.Benchmarks.Data.Key.RSA.txt")) | ||
{ | ||
var privateKey = new PrivateKeyFile(s); | ||
return (KeyHostAlgorithm) privateKey.HostKeyAlgorithms.First(); | ||
} | ||
} | ||
|
||
[Benchmark()] | ||
public HostKeyEventArgs Constructor() | ||
{ | ||
return new HostKeyEventArgs(_keyHostAlgorithm); | ||
} | ||
|
||
[Benchmark()] | ||
public (string, string) CalculateFingerPrintSHA256AndMD5() | ||
{ | ||
var test = new HostKeyEventArgs(_keyHostAlgorithm); | ||
|
||
return (test.FingerPrintSHA256, test.FingerPrintMD5); | ||
} | ||
|
||
[Benchmark()] | ||
public string CalculateFingerPrintSHA256() | ||
{ | ||
var test = new HostKeyEventArgs(_keyHostAlgorithm); | ||
|
||
return test.FingerPrintSHA256; | ||
} | ||
|
||
[Benchmark()] | ||
public byte[] CalculateFingerPrint() | ||
{ | ||
var test = new HostKeyEventArgs(_keyHostAlgorithm); | ||
|
||
return test.FingerPrint; | ||
} | ||
|
||
[Benchmark()] | ||
public string CalculateFingerPrintMD5() | ||
{ | ||
var test = new HostKeyEventArgs(_keyHostAlgorithm); | ||
|
||
return test.FingerPrintSHA256; | ||
} | ||
} | ||
} |
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