Merge pull request #6244 from SergerGood/main
Added example of perfomance test
This commit is contained in:
commit
28d8f2fcee
|
|
@ -1,6 +1,4 @@
|
|||
<Project>
|
||||
|
||||
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet"/>
|
||||
|
|
|
|||
14
test/performance/Elsa.Workflows.PerformanceTests/Config.cs
Normal file
14
test/performance/Elsa.Workflows.PerformanceTests/Config.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Diagnosers;
|
||||
using BenchmarkDotNet.Exporters;
|
||||
|
||||
namespace Elsa.Workflows.PerformanceTests;
|
||||
|
||||
public class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
AddExporter(MarkdownExporter.GitHub);
|
||||
AddDiagnoser(MemoryDiagnoser.Default);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
using BenchmarkDotNet.Attributes;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Workflows.Activities;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Elsa.Workflows.PerformanceTests;
|
||||
|
||||
[Config(typeof(Config))]
|
||||
public class ConsoleActivitiesBenchmark
|
||||
{
|
||||
private WriteLine _writeLineWorkflow;
|
||||
private IWorkflowRunner _workflowRunner;
|
||||
private ServiceProvider _serviceProvider;
|
||||
|
||||
[GlobalSetup]
|
||||
public void GlobalSetup()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddElsa();
|
||||
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
_workflowRunner = _serviceProvider.GetRequiredService<IWorkflowRunner>();
|
||||
|
||||
_writeLineWorkflow = new WriteLine("Hello, World!");
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public async Task WriteLine() => await _workflowRunner.RunAsync(_writeLineWorkflow);
|
||||
|
||||
[GlobalCleanup]
|
||||
public void GlobalCleanup() => _serviceProvider.Dispose();
|
||||
}
|
||||
|
|
@ -6,11 +6,11 @@
|
|||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
<OutputType>Exe</OutputType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit"/>
|
||||
<ProjectReference Include="..\..\..\src\modules\Elsa\Elsa.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
using BenchmarkDotNet.Running;
|
||||
|
||||
BenchmarkSwitcher switcher = new(typeof(Program).Assembly);
|
||||
switcher.Run(args);
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
namespace Elsa.Workflows.PerformanceTests;
|
||||
|
||||
public class UnitTest1
|
||||
{
|
||||
[Fact]
|
||||
public void Test1()
|
||||
{
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue