-
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
Showing
40 changed files
with
1,539 additions
and
951 deletions.
There are no files selected for viewing
145 changes: 145 additions & 0 deletions
145
Benchmarks/Falko.Talkie.Benchmarks.Sequences/Benchmarks/FirstAndLastAndContainsBenchmark.cs
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,145 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Engines; | ||
using Talkie.Models; | ||
using Talkie.Sequences; | ||
|
||
namespace Talkie.Benchmarks.Benchmarks; | ||
|
||
[MemoryDiagnoser] | ||
[SimpleJob(RunStrategy.Throughput)] | ||
public class FirstAndLastAndContainsBenchmark | ||
{ | ||
private const int Capacity = 10; | ||
|
||
private FrozenSequence<Reference>? _frozenSequence; | ||
|
||
private IEnumerable<Reference>? _referenceFrozenSequence; | ||
|
||
private RemovableSequence<Reference>? _removableSequence; | ||
|
||
private Sequence<Reference>? _sequence; | ||
|
||
private LinkedList<Reference>? _linkedList; | ||
|
||
private List<Reference>? _list; | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
SetupFrozenSequence(); | ||
SetupRemovableSequence(); | ||
SetupSequence(); | ||
SetupLinkedList(); | ||
SetupList(); | ||
} | ||
|
||
public void SetupFrozenSequence() | ||
{ | ||
var sequence = new List<Reference>(); | ||
|
||
for (var i = 0; i < Capacity; i++) | ||
{ | ||
sequence.Add(Reference.Shared); | ||
} | ||
|
||
_frozenSequence = sequence.ToFrozenSequence(); | ||
_referenceFrozenSequence = _frozenSequence; | ||
} | ||
|
||
public void SetupRemovableSequence() | ||
{ | ||
var removableSequence = new RemovableSequence<Reference>(); | ||
|
||
for (var i = 0; i < Capacity; i++) | ||
{ | ||
_ = removableSequence.Add(Reference.Shared); | ||
} | ||
|
||
_removableSequence = removableSequence; | ||
} | ||
|
||
public void SetupSequence() | ||
{ | ||
var sequence = new Sequence<Reference>(); | ||
|
||
for (var i = 0; i < Capacity; i++) | ||
{ | ||
sequence.Add(Reference.Shared); | ||
} | ||
|
||
_sequence = sequence; | ||
} | ||
|
||
public void SetupLinkedList() | ||
{ | ||
var linkedList = new LinkedList<Reference>(); | ||
|
||
for (var i = 0; i < Capacity; i++) | ||
{ | ||
_ = linkedList.AddLast(Reference.Shared); | ||
} | ||
|
||
_linkedList = linkedList; | ||
} | ||
|
||
public void SetupList() | ||
{ | ||
var list = new List<Reference>(); | ||
|
||
for (var i = 0; i < Capacity; i++) | ||
{ | ||
list.Add(Reference.Shared); | ||
} | ||
|
||
_list = list; | ||
} | ||
|
||
[Benchmark] | ||
public void RunFrozenSequenceForeach() | ||
{ | ||
_ = _frozenSequence!.First(); | ||
_ = _frozenSequence!.Last(); | ||
} | ||
|
||
[Benchmark] | ||
public void RunReferenceFrozenSequenceForeach() | ||
{ | ||
_ = _referenceFrozenSequence!.First(); | ||
_ = _referenceFrozenSequence!.Last(); | ||
} | ||
|
||
[Benchmark] | ||
public void RunReferenceSequencingFrozenSequenceForeach() | ||
{ | ||
_ = _referenceFrozenSequence!.Sequencing().First(); | ||
_ = _referenceFrozenSequence!.Sequencing().Last(); | ||
} | ||
|
||
[Benchmark] | ||
public void RunRemovableSequenceForeach() | ||
{ | ||
_ = _removableSequence!.First(); | ||
_ = _removableSequence!.Last(); | ||
} | ||
|
||
[Benchmark] | ||
public void RunSequenceForeach() | ||
{ | ||
_ = _sequence!.First(); | ||
_ = _sequence!.Last(); | ||
} | ||
|
||
[Benchmark] | ||
public void RunLinkedListForeach() | ||
{ | ||
_ = _linkedList!.First(); | ||
_ = _linkedList!.Last(); | ||
} | ||
|
||
[Benchmark] | ||
public void RunListForeach() | ||
{ | ||
_ = _list!.First(); | ||
_ = _list!.Last(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,26 @@ | ||
using BenchmarkDotNet.Running; | ||
using Talkie.Benchmarks.Benchmarks; | ||
using Talkie.Flows; | ||
using Talkie.Pipelines.Handling; | ||
using Talkie.Pipelines.Intercepting; | ||
using Talkie.Signals; | ||
|
||
BenchmarkRunner.Run<AddBenchmark>(); | ||
BenchmarkRunner.Run<RemoveBenchmark>(); | ||
BenchmarkRunner.Run<ForeachBenchmark>(); | ||
using var flow = new SignalFlow(); | ||
|
||
flow.Subscribe<UserEntrySignal>(signals => signals | ||
.Where(signal => signal.LastName is "Falko") | ||
.Take(1) | ||
.Handle(context => Console | ||
.WriteLine(context | ||
.Signal))); | ||
|
||
flow.Subscribe<UserEntrySignal>(signals => signals | ||
.Where(signal => signal.LastName is "Borodin") | ||
.Take(1) | ||
.Handle(context => Console | ||
.WriteLine(context | ||
.Signal))); | ||
|
||
await flow.PublishAsync(new UserEntrySignal("Rima", "Falko")); | ||
await flow.PublishAsync(new UserEntrySignal("Timur", "Falko")); | ||
await flow.PublishAsync(new UserEntrySignal("Misha", "Borodin")); | ||
|
||
file sealed record UserEntrySignal(string FirstName, string LastName) : Signal; |
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
<Project> | ||
<ItemGroup Label="Dependencies"> | ||
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" /> | ||
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.0" /> | ||
<PackageVersion Include="Serilog" Version="4.1.0" /> | ||
<PackageVersion Include="Serilog.Extensions.Hosting" Version="8.0.0" /> | ||
<PackageVersion Include="Serilog.Sinks.Console" Version="6.0.0" /> | ||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" /> | ||
<PackageVersion Include="NUnit" Version="4.2.2" /> | ||
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" /> | ||
<PackageVersion Include="NUnit.Analyzers" Version="4.4.0" /> | ||
<PackageVersion Include="coverlet.collector" Version="6.0.2" /> | ||
</ItemGroup> | ||
</Project> | ||
<ItemGroup Label="Dependencies"> | ||
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" /> | ||
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.0" /> | ||
<PackageVersion Include="Serilog" Version="4.1.0" /> | ||
<PackageVersion Include="Serilog.Extensions.Hosting" Version="8.0.0" /> | ||
<PackageVersion Include="Serilog.Sinks.Console" Version="6.0.0" /> | ||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" /> | ||
<PackageVersion Include="NUnit" Version="4.2.2" /> | ||
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" /> | ||
<PackageVersion Include="NUnit.Analyzers" Version="4.4.0" /> | ||
<PackageVersion Include="coverlet.collector" Version="6.0.2" /> | ||
</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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,37 @@ | ||
<Solution> | ||
<Folder Name="/Assets/"> | ||
<File Path="Common.Build.props" /> | ||
<File Path="nuget.config" /> | ||
<File Path=".gitignore" /> | ||
<File Path=".gitattributes" /> | ||
<File Path="ReadMe.md" /> | ||
<File Path="Benchmarks.Build.props" /> | ||
<File Path="Examples.Build.props" /> | ||
<File Path="Logo512.png" /> | ||
<File Path="Sources.Build.props" /> | ||
<File Path="Tests.Build.props" /> | ||
<File Path="Directory.Packages.props" /> | ||
<File Path="Icon64.png" /> | ||
<File Path="License.md" /> | ||
</Folder> | ||
|
||
<Folder Name="/Benchmarks/"> | ||
<Project Path="Benchmarks\Falko.Talkie.Benchmarks.Sequences\Falko.Talkie.Benchmarks.Sequences.csproj" Type="Classic C#" /> | ||
</Folder> | ||
|
||
<Folder Name="/Examples/"> | ||
<Project Path="Examples\Falko.Talkie.Examples.Microsoft.Hosting\Falko.Talkie.Examples.Microsoft.Hosting.csproj" Type="Classic C#" /> | ||
</Folder> | ||
|
||
<Folder Name="/Sources/"> | ||
<Project Path="Sources\Falko.Talkie.Bridges.Telegram\Falko.Talkie.Bridges.Telegram.csproj" Type="Classic C#" /> | ||
<Project Path="Sources\Falko.Talkie.Core\Falko.Talkie.Core.csproj" Type="Classic C#" /> | ||
<Project Path="Sources\Falko.Talkie.Microsoft.Hosting\Falko.Talkie.Microsoft.Hosting.csproj" Type="Classic C#" /> | ||
<Project Path="Sources\Falko.Talkie.Platforms.Telegram\Falko.Talkie.Platforms.Telegram.csproj" Type="Classic C#" /> | ||
<Project Path="Sources\Falko.Talkie.Platforms\Falko.Talkie.Platforms.csproj" Type="Classic C#" /> | ||
<Project Path="Sources\Falko.Talkie.Signals.Adapters\Falko.Talkie.Signals.Adapters.csproj" Type="Classic C#" /> | ||
<Project Path="Sources\Falko.Talkie.Signals.Connections\Falko.Talkie.Signals.Connections.csproj" Type="Classic C#" /> | ||
<Project Path="Sources\Falko.Talkie.Signals.Extensions\Falko.Talkie.Signals.Extensions.csproj" Type="Classic C#" /> | ||
<Project Path="Sources\Falko.Talkie.Signals\Falko.Talkie.Signals.csproj" Type="Classic C#" /> | ||
</Folder> | ||
|
||
<Folder Name="/Tests/"> | ||
<Project Path="Tests\Falko.Talkie.Tests.Sequences\Falko.Talkie.Tests.Sequences.csproj" Type="Classic C#" /> | ||
</Folder> | ||
</Solution> | ||
<Folder Name="/Assets/"> | ||
<File Path="Common.Build.props" /> | ||
<File Path="nuget.config" /> | ||
<File Path=".gitignore" /> | ||
<File Path=".gitattributes" /> | ||
<File Path="ReadMe.md" /> | ||
<File Path="Benchmarks.Build.props" /> | ||
<File Path="Examples.Build.props" /> | ||
<File Path="Logo512.png" /> | ||
<File Path="Sources.Build.props" /> | ||
<File Path="Tests.Build.props" /> | ||
<File Path="Directory.Packages.props" /> | ||
<File Path="Icon64.png" /> | ||
<File Path="License.md" /> | ||
</Folder> | ||
<Folder Name="/Benchmarks/"> | ||
<Project Path="Benchmarks\Falko.Talkie.Benchmarks.Sequences\Falko.Talkie.Benchmarks.Sequences.csproj" Type="Classic C#" /> | ||
</Folder> | ||
<Folder Name="/Examples/"> | ||
<Project Path="Examples\Falko.Talkie.Examples.Microsoft.Hosting\Falko.Talkie.Examples.Microsoft.Hosting.csproj" Type="Classic C#" /> | ||
</Folder> | ||
<Folder Name="/Sources/"> | ||
<Project Path="Sources\Falko.Talkie.Bridges.Telegram\Falko.Talkie.Bridges.Telegram.csproj" Type="Classic C#" /> | ||
<Project Path="Sources\Falko.Talkie.Core\Falko.Talkie.Core.csproj" Type="Classic C#" /> | ||
<Project Path="Sources\Falko.Talkie.Microsoft.Hosting\Falko.Talkie.Microsoft.Hosting.csproj" Type="Classic C#" /> | ||
<Project Path="Sources\Falko.Talkie.Platforms.Telegram\Falko.Talkie.Platforms.Telegram.csproj" Type="Classic C#" /> | ||
<Project Path="Sources\Falko.Talkie.Platforms\Falko.Talkie.Platforms.csproj" Type="Classic C#" /> | ||
<Project Path="Sources\Falko.Talkie.Signals.Adapters\Falko.Talkie.Signals.Adapters.csproj" Type="Classic C#" /> | ||
<Project Path="Sources\Falko.Talkie.Signals.Connections\Falko.Talkie.Signals.Connections.csproj" Type="Classic C#" /> | ||
<Project Path="Sources\Falko.Talkie.Signals.Extensions\Falko.Talkie.Signals.Extensions.csproj" Type="Classic C#" /> | ||
<Project Path="Sources\Falko.Talkie.Signals\Falko.Talkie.Signals.csproj" Type="Classic C#" /> | ||
</Folder> | ||
<Folder Name="/Tests/"> | ||
<Project Path="Tests\Falko.Talkie.Tests.Sequences\Falko.Talkie.Tests.Sequences.csproj" Type="Classic C#" /> | ||
</Folder> | ||
</Solution> |
Oops, something went wrong.