diff --git a/test/performance/Directory.Build.props b/test/performance/Directory.Build.props index 0e0af60ea..674d5ca9b 100644 --- a/test/performance/Directory.Build.props +++ b/test/performance/Directory.Build.props @@ -1,6 +1,4 @@ - - diff --git a/test/performance/Elsa.Workflows.PerformanceTests/Config.cs b/test/performance/Elsa.Workflows.PerformanceTests/Config.cs new file mode 100644 index 000000000..307deecce --- /dev/null +++ b/test/performance/Elsa.Workflows.PerformanceTests/Config.cs @@ -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); + } +} \ No newline at end of file diff --git a/test/performance/Elsa.Workflows.PerformanceTests/ConsoleActivitiesBenchmark.cs b/test/performance/Elsa.Workflows.PerformanceTests/ConsoleActivitiesBenchmark.cs new file mode 100644 index 000000000..9f214cf1b --- /dev/null +++ b/test/performance/Elsa.Workflows.PerformanceTests/ConsoleActivitiesBenchmark.cs @@ -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(); + + _writeLineWorkflow = new WriteLine("Hello, World!"); + } + + [Benchmark] + public async Task WriteLine() => await _workflowRunner.RunAsync(_writeLineWorkflow); + + [GlobalCleanup] + public void GlobalCleanup() => _serviceProvider.Dispose(); +} \ No newline at end of file diff --git a/test/performance/Elsa.Workflows.PerformanceTests/Elsa.Workflows.PerformanceTests.csproj b/test/performance/Elsa.Workflows.PerformanceTests/Elsa.Workflows.PerformanceTests.csproj index fc1b99f93..ee58b4574 100644 --- a/test/performance/Elsa.Workflows.PerformanceTests/Elsa.Workflows.PerformanceTests.csproj +++ b/test/performance/Elsa.Workflows.PerformanceTests/Elsa.Workflows.PerformanceTests.csproj @@ -6,11 +6,11 @@ enable false - true + Exe - + diff --git a/test/performance/Elsa.Workflows.PerformanceTests/Program.cs b/test/performance/Elsa.Workflows.PerformanceTests/Program.cs new file mode 100644 index 000000000..af752d90e --- /dev/null +++ b/test/performance/Elsa.Workflows.PerformanceTests/Program.cs @@ -0,0 +1,4 @@ +using BenchmarkDotNet.Running; + +BenchmarkSwitcher switcher = new(typeof(Program).Assembly); +switcher.Run(args); \ No newline at end of file diff --git a/test/performance/Elsa.Workflows.PerformanceTests/UnitTest1.cs b/test/performance/Elsa.Workflows.PerformanceTests/UnitTest1.cs deleted file mode 100644 index 5eecbccb1..000000000 --- a/test/performance/Elsa.Workflows.PerformanceTests/UnitTest1.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Elsa.Workflows.PerformanceTests; - -public class UnitTest1 -{ - [Fact] - public void Test1() - { - } -} \ No newline at end of file