Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Benchmark/Benchmark.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30621.155
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Benchmark", "Benchmark\Benchmark.csproj", "{43585CD2-9507-48FC-8A39-325D53A6B2C3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{65A66F13-289C-44A0-BD3D-B00E57753E9F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{43585CD2-9507-48FC-8A39-325D53A6B2C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43585CD2-9507-48FC-8A39-325D53A6B2C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43585CD2-9507-48FC-8A39-325D53A6B2C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43585CD2-9507-48FC-8A39-325D53A6B2C3}.Release|Any CPU.Build.0 = Release|Any CPU
{65A66F13-289C-44A0-BD3D-B00E57753E9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{65A66F13-289C-44A0-BD3D-B00E57753E9F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{65A66F13-289C-44A0-BD3D-B00E57753E9F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{65A66F13-289C-44A0-BD3D-B00E57753E9F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {50156758-2800-4502-AE2B-0A243EDDFBEE}
EndGlobalSection
EndGlobal
12 changes: 12 additions & 0 deletions Benchmark/Benchmark/Benchmark.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
</ItemGroup>

</Project>
13 changes: 13 additions & 0 deletions Benchmark/Benchmark/EasiestTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using BenchmarkDotNet.Running;
using System;
using System.Collections.Generic;
using System.Text;

namespace Benchmark
{
class EasiestTest
{
public static void OnTestsStart() =>
BenchmarkRunner.Run<TestClass>();
}
}
14 changes: 14 additions & 0 deletions Benchmark/Benchmark/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;

namespace Benchmark
{
class Program
{
static void Main(string[] args)
{
EasiestTest.OnTestsStart();

Console.ReadKey();
}
}
}
56 changes: 56 additions & 0 deletions Benchmark/Benchmark/TestClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using BenchmarkDotNet;
using System.Text;
using BenchmarkDotNet.Attributes;

namespace Benchmark
{
class TestClass
{
void SimulateWork()
{
StringBuilder builder = new StringBuilder();
for (int i = 0; i < 10000; i++)
builder.Append(i.ToString());
}

public static void PbStaticVoid()
{
StringBuilder builder = new StringBuilder();
for (int i = 0; i < 10000; i++)
builder.Append(i.ToString());
}

[Benchmark(Description = "PbVoid")]
public void PbVoid() =>
SimulateWork();

[Benchmark(Description = "PbVirtualVoid")]
public virtual void PbVirtualVoid() =>
SimulateWork();

public static void PbGenericStaticVoid<T>()
{
StringBuilder builder = new StringBuilder();
for (int i = 0; i < 10000; i++)
builder.Append(i.ToString());
}

public static void PbGenericStaticVoid() =>
PbGenericStaticVoid<int>();


[Benchmark(Description = "PbGenericVoid")]
public void PbGenericVoid() =>
SimulateWork();

[Benchmark(Description = "PbDynamic")]
public dynamic PbDynamic()
{
StringBuilder builder = new StringBuilder();
for (int i = 0; i < 10000; i++)
builder.Append(i.ToString());
return builder;
}
}
}
15 changes: 15 additions & 0 deletions Benchmark/Tests/Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0"/>
</ItemGroup>

</Project>
18 changes: 18 additions & 0 deletions Benchmark/Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using NUnit.Framework;

namespace Tests
{
public class Tests
{
[SetUp]
public void Setup()
{
}

[Test]
public void Test1()
{
Assert.Pass();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем?

}
}
}