Files
SSH.NET/test/Renci.SshNet.Benchmarks/Common/HostKeyEventArgsBenchmarks.cs
mus65 86dc811458 Drop net6.0 target (#1580)
* Drop net6.0 target

* Update src/Renci.SshNet/Common/TaskToAsyncResult.cs

Co-authored-by: Rob Hague <rob.hague00@gmail.com>

* remove redundant #if

for some reason this made the compiler suddenly
realize that the plain text variables are unused.

* use TargetFrameworkIdentifier

this doesn't work in Directory.Build.props, moved it to Directory.Build.targets.

* fix null reference warnings in Benchmarks

seems like the warnings were (somehow) disabled here
before and were fixed by the previous TargetFrameworkIdentifier
change.

* fix unused plainTextOffset in AesGcmCipher.BclImpl

* CI retry

* more cosmetics

* more

* update README

* Revert "use TargetFrameworkIdentifier"

This reverts commit 076ede161d.

---------

Co-authored-by: Rob Hague <rob.hague00@gmail.com>
Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
2025-02-19 13:37:38 +01:00

66 lines
1.7 KiB
C#

using BenchmarkDotNet.Attributes;
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(HostKeyEventArgsBenchmarks).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;
}
}
}