-
-
Notifications
You must be signed in to change notification settings - Fork 970
Integration benchmark tests #1298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
WojciechNagorski
merged 6 commits into
sshnet:develop
from
WojciechNagorski:integration-benchmark-tests
Jan 28, 2024
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
aec4168
Integration benchmark tests
WojciechNagorski 9869409
Fixes
WojciechNagorski 962b6bb
Merge master
WojciechNagorski 70670a7
Write with encoding
WojciechNagorski fda166c
Update src/Renci.SshNet/Common/SshDataStream.cs
WojciechNagorski e6a8684
Add more benchmarks
WojciechNagorski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -17,4 +17,5 @@ | |
| <ItemGroup> | ||
| <EmbeddedResource Include="..\Data\*" LinkBase="Data" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> | ||
This file contains hidden or 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,72 @@ | ||
| [*.cs] | ||
|
|
||
| #### Sonar rules #### | ||
|
|
||
| # S125: Sections of code should not be commented out | ||
| https://rules.sonarsource.com/csharp/RSPEC-125/ | ||
| dotnet_diagnostic.S125.severity = suggestion | ||
|
|
||
| # S1118: Utility classes should not have public constructors | ||
| # https://rules.sonarsource.com/csharp/RSPEC-1118/ | ||
| dotnet_diagnostic.S1118.severity = suggestion | ||
|
|
||
| # S1450: Private fields only used as local variables in methods should become local variables | ||
| # https://rules.sonarsource.com/csharp/RSPEC-1450/ | ||
| dotnet_diagnostic.S1450.severity = suggestion | ||
|
|
||
| # S4144: Methods should not have identical implementations | ||
| # https://rules.sonarsource.com/csharp/RSPEC-4144/ | ||
| dotnet_diagnostic.S4144.severity = suggestion | ||
|
|
||
| #### SYSLIB diagnostics #### | ||
|
|
||
|
|
||
| #### StyleCop Analyzers rules #### | ||
|
|
||
| # SA1028: Code must not contain trailing whitespace | ||
| # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md | ||
| dotnet_diagnostic.SA1028.severity = suggestion | ||
|
|
||
| # SA1414: Tuple types in signatures should have element names | ||
| https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1414.md | ||
| dotnet_diagnostic.SA1414.severity = suggestion | ||
|
|
||
| # SA1400: Access modifier must be declared | ||
| # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1400.md | ||
| dotnet_diagnostic.SA1400.severity = suggestion | ||
|
|
||
| # SA1401: Fields must be private | ||
| # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1401.md | ||
| dotnet_diagnostic.SA1401.severity = suggestion | ||
|
|
||
| # SA1411: Attribute constructor must not use unnecessary parenthesis | ||
| # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1411.md | ||
| dotnet_diagnostic.SA1411.severity = suggestion | ||
|
|
||
| # SA1505: Opening braces must not be followed by blank line | ||
| # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1505.md | ||
| dotnet_diagnostic.SA1505.severity = suggestion | ||
|
|
||
| # SA1512: Single line comments must not be followed by blank line | ||
| # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1512.md | ||
| dotnet_diagnostic.SA1512.severity = suggestion | ||
|
|
||
| # SA1513: Closing brace must be followed by blank line | ||
| # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1513.md | ||
| dotnet_diagnostic.SA1513.severity = suggestion | ||
|
|
||
| #### Meziantou.Analyzer rules #### | ||
|
|
||
| # MA0003: Add parameter name to improve readability | ||
| # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0003.md | ||
| dotnet_diagnostic.MA0003.severity = suggestion | ||
|
|
||
| # MA0053: Make class sealed | ||
| # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0053.md | ||
| dotnet_diagnostic.MA0053.severity = suggestion | ||
|
|
||
| #### .NET Compiler Platform analysers rules #### | ||
|
|
||
| # CA2000: Dispose objects before losing scope | ||
| # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2000 | ||
| dotnet_diagnostic.CA2000.severity = suggestion |
19 changes: 19 additions & 0 deletions
19
test/Renci.SshNet.IntegrationBenchmarks/IntegrationBenchmarkBase.cs
This file contains hidden or 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,19 @@ | ||
| using Renci.SshNet.IntegrationTests.TestsFixtures; | ||
|
|
||
| namespace Renci.SshNet.IntegrationBenchmarks | ||
| { | ||
| public class IntegrationBenchmarkBase | ||
| { | ||
| #pragma warning disable CA1822 // Mark members as static | ||
| public async Task GlobalSetup() | ||
| { | ||
| await InfrastructureFixture.Instance.InitializeAsync().ConfigureAwait(false); | ||
| } | ||
|
|
||
| public async Task GlobalCleanup() | ||
| { | ||
| await InfrastructureFixture.Instance.DisposeAsync().ConfigureAwait(false); | ||
| } | ||
| #pragma warning restore CA1822 // Mark members as static | ||
| } | ||
| } |
This file contains hidden or 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,12 @@ | ||
| using BenchmarkDotNet.Running; | ||
|
|
||
| namespace Renci.SshNet.IntegrationBenchmarks | ||
| { | ||
| public static class Program | ||
| { | ||
| public static void Main(string[] args) | ||
| { | ||
| _ = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); | ||
| } | ||
| } | ||
| } |
25 changes: 25 additions & 0 deletions
25
test/Renci.SshNet.IntegrationBenchmarks/Renci.SshNet.IntegrationBenchmarks.csproj
This file contains hidden or 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,25 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="BenchmarkDotNet" Version="0.13.9" /> | ||
| <!-- <PackageReference Include="SSH.NET" Version="2023.0.0" /> --> | ||
| <PackageReference Include="SSH.NET" Version="2023.0.0" ExcludeAssets="All" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\src\Renci.SshNet\Renci.SshNet.csproj" /> | ||
| <ProjectReference Include="..\Renci.SshNet.IntegrationTests\Renci.SshNet.IntegrationTests.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <EmbeddedResource Include="..\Data\*" LinkBase="Data" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
38 changes: 38 additions & 0 deletions
38
test/Renci.SshNet.IntegrationBenchmarks/SshClientBenchmark.cs
This file contains hidden or 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,38 @@ | ||
| using BenchmarkDotNet.Attributes; | ||
|
|
||
| using Renci.SshNet.IntegrationTests.TestsFixtures; | ||
|
|
||
| namespace Renci.SshNet.IntegrationBenchmarks | ||
| { | ||
| [MemoryDiagnoser] | ||
| [SimpleJob] | ||
| public class SshClientBenchmark : IntegrationBenchmarkBase | ||
| { | ||
| private readonly InfrastructureFixture _infrastructureFixture; | ||
|
|
||
| public SshClientBenchmark() | ||
| { | ||
| _infrastructureFixture = InfrastructureFixture.Instance; | ||
| } | ||
|
|
||
| [GlobalSetup] | ||
| public async Task Setup() | ||
| { | ||
| await GlobalSetup().ConfigureAwait(false); | ||
| } | ||
|
|
||
| [GlobalCleanup] | ||
| public async Task Cleanup() | ||
| { | ||
| await GlobalCleanup().ConfigureAwait(false); | ||
| } | ||
|
|
||
| [Benchmark] | ||
| public string Connect() | ||
| { | ||
| using var sshClient = new SshClient(_infrastructureFixture.SshServerHostName, _infrastructureFixture.SshServerPort, _infrastructureFixture.User.UserName, _infrastructureFixture.User.Password); | ||
| sshClient.Connect(); | ||
| return sshClient.RunCommand("echo $'test !@#$%^&*()_+{}:,./<>[];\\|'").Result; | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.