Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ProtocolReader Benchmarks #28

Merged
merged 3 commits into from
Jan 5, 2020
Merged

Conversation

alistairjevans
Copy link
Contributor

In these changes I've:

  • Added a Bedrock.Framework.Benchmarks console project
  • Configured an artifacts path with timestamped folders.
  • Added the MemoryDiagnoser.
  • Defined a benchmark class, ProtocolReaderBenchmarks
  • Added three benchmarks to that class:
    • PipeOnly - This is a baseline benchmark to determine the cost of only doing pipe write and read (without Bedrock).
    • ReadProtocolWithWholeMessageAvailable - A benchmark for when the entire message is available (so the ProtocolReader.ReadAsync can just return immediately).
    • ReadProtocolWithPartialMessageAvailable - A benchmark for when the entire message is not available, and the ReadAsync method must go round again.

The ProtocolReader benchmarks do the absolute bare minimum of message reading work with a local IMessageReader implementation that just moves the positions along and returns whether the whole expected size is available.

Fixes #23.

Local Results:

BenchmarkDotNet=v0.12.0, OS=Windows 10.0.18363
AMD Ryzen 5 2500U with Radeon Vega Mobile Gfx, 1 CPU, 8 logical and 4 physical cores
.NET Core SDK=3.1.100
  [Host]     : .NET Core 3.1.0 (CoreCLR 4.700.19.56402, CoreFX 4.700.19.56404), X64 RyuJIT
  DefaultJob : .NET Core 3.1.0 (CoreCLR 4.700.19.56402, CoreFX 4.700.19.56404), X64 RyuJIT

Method MessageSize Mean Error StdDev Ratio RatioSD Gen 0 Gen 1 Gen 2 Allocated
PipeOnly 10 405.6 ns 4.05 ns 3.59 ns 1.00 0.00 - - - -
ReadProtocolWithWholeMessageAvailable 10 476.9 ns 8.72 ns 8.15 ns 1.17 0.02 - - - -
ReadProtocolWithPartialMessageAvailable 10 622.6 ns 9.74 ns 9.11 ns 1.54 0.03 - - - -
PipeOnly 100 404.5 ns 4.29 ns 4.01 ns 1.00 0.00 - - - -
ReadProtocolWithWholeMessageAvailable 100 486.5 ns 8.34 ns 7.80 ns 1.20 0.02 - - - -
ReadProtocolWithPartialMessageAvailable 100 629.4 ns 9.36 ns 8.75 ns 1.56 0.03 - - - -
PipeOnly 1000 438.1 ns 5.05 ns 4.72 ns 1.00 0.00 - - - -
ReadProtocolWithWholeMessageAvailable 1000 582.3 ns 11.46 ns 16.44 ns 1.35 0.03 - - - -
ReadProtocolWithPartialMessageAvailable 1000 734.9 ns 12.15 ns 10.77 ns 1.68 0.03 - - - -

class SimpleReader : IMessageReader<int>
{
private readonly int messageSize;

Copy link
Owner

Choose a reason for hiding this comment

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

small nit: remove extra space

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done; I've got so used to the analysers catching this for me.

@davidfowl davidfowl merged commit 08273ea into davidfowl:master Jan 5, 2020
@davidfowl
Copy link
Owner

Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add performance tests
2 participants