-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Emil Koutanov
committed
Jan 29, 2024
1 parent
fe13fdc
commit bf0eea2
Showing
10 changed files
with
129 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -261,3 +261,6 @@ FakesAssemblies/ | |
|
||
# Visual Studio 6 workspace options file | ||
*.opt | ||
|
||
.idea | ||
BenchmarkDotNet.Artifacts |
This file contains 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,34 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using BenchmarkDotNet; | ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace Actors.Benchmarks; | ||
|
||
public class AckDelivery | ||
{ | ||
class WorkItem | ||
{ | ||
public TaskCompletionSource Completion { get; } = new(); | ||
} | ||
|
||
class AckDeliveryWorker : Actor<WorkItem> | ||
{ | ||
protected override Task Perform(Inbox inbox) | ||
{ | ||
var workItem = inbox.Receive(); | ||
workItem.Completion.SetResult(); | ||
return Task.CompletedTask; | ||
} | ||
} | ||
|
||
private readonly AckDeliveryWorker worker = new(); | ||
|
||
[Benchmark] | ||
public async Task SendAndAwaitAck() | ||
{ | ||
var workItem = new WorkItem(); | ||
worker.Send(workItem); | ||
await workItem.Completion.Task; | ||
} | ||
} |
This file contains 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,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<DebugSymbols>true</DebugSymbols> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<Optimize>true</Optimize> | ||
<Configuration>Release</Configuration> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" /> | ||
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.12" Condition="'$(OS)' == 'Windows_NT'"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Actors\Actors.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains 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,33 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using BenchmarkDotNet; | ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace Actors.Benchmarks; | ||
|
||
public class FireAndForget | ||
{ | ||
class FireAndForgetWorker : Actor<int> | ||
{ | ||
protected override Task Perform(Inbox inbox) | ||
{ | ||
inbox.Receive(); | ||
return Task.CompletedTask; | ||
} | ||
} | ||
|
||
private readonly FireAndForgetWorker worker = new(); | ||
|
||
[Params(1_000)] | ||
public int numMessages; | ||
|
||
[Benchmark] | ||
public async Task SendAndDrain() | ||
{ | ||
for (var i = 0; i < numMessages; i++) | ||
{ | ||
worker.Send(i); | ||
} | ||
await worker.Drain(); | ||
} | ||
} |
This file contains 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,18 @@ | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Running; | ||
|
||
namespace Actors.Benchmarks | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
var config = DefaultConfig.Instance; | ||
BenchmarkRunner.Run<FireAndForget>(config, args); | ||
BenchmarkRunner.Run<AckDelivery>(config, args); | ||
|
||
// Use this to select benchmarks from the console: | ||
// var summaries = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, config); | ||
} | ||
} | ||
} |
This file contains 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 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 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 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