mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-10 17:25:51 +00:00
f172ac587c
* Exludes the test projects from code coverage reports * Removes MessageAttribute in favor of properties on Message class * Benchmark for removal of MessageAttribute
36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
using BenchmarkDotNet.Attributes;
|
|
|
|
using Renci.SshNet.Common;
|
|
using Renci.SshNet.Messages;
|
|
using Renci.SshNet.Messages.Transport;
|
|
|
|
namespace Renci.SshNet.Benchmarks.Messages
|
|
{
|
|
[MemoryDiagnoser]
|
|
public class MessageBenchmarks
|
|
{
|
|
[Benchmark]
|
|
public Message WriteBytes()
|
|
{
|
|
using var sshDataStream = new SshDataStream(SshData.DefaultCapacity);
|
|
var bannerMessage = new WritableDisconnectMessage(DisconnectReason.ServiceNotAvailable, "Goodbye");
|
|
bannerMessage.WritePrivateBytes(sshDataStream);
|
|
|
|
return bannerMessage; // Avoid JIT elimination
|
|
}
|
|
|
|
private sealed class WritableDisconnectMessage : DisconnectMessage
|
|
{
|
|
public WritableDisconnectMessage(DisconnectReason reasonCode, string message)
|
|
: base(reasonCode, message)
|
|
{
|
|
}
|
|
|
|
public void WritePrivateBytes(SshDataStream sshDataStream)
|
|
{
|
|
WriteBytes(sshDataStream);
|
|
}
|
|
}
|
|
}
|
|
}
|