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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmarks vs Mediator #14

Open
Naxaliav opened this issue Apr 19, 2023 · 2 comments
Open

Benchmarks vs Mediator #14

Naxaliav opened this issue Apr 19, 2023 · 2 comments

Comments

@Naxaliav
Copy link

Hi 馃憢,
have you looked into this library? https://github.com/martinothamar/Mediator (it uses source generators underneath).
Just wondering what would be the benchmarks vs this implementation :)

@lawrence-laz
Copy link
Owner

lawrence-laz commented Apr 19, 2023

Hi, I have looked into it a bit, you can check out the feature parity table in the main readme.md.

I don't have a benchmark to compare it to this library though, but I'd expect Mediator to be faster. I might try it out a bit later.

Generally thinking about GenericPipeline though, if a design calls for a standard mediator pattern implementation to handle application requests, I'd always go with either MediatR or this Mediator. GenericPipeline is a better fit only where you need more control, either your handlers/behaviors are dynamically changing or the pipeline is being build at runtime based on user configuration (and handlers are not part of dependency injection container). At least it was specifically built with such scenario in mind. 馃檪

@lawrence-laz
Copy link
Owner

lawrence-laz commented Apr 19, 2023

So I did an initial benchmark and surprisingly Mediator is 40 ns slower than GenericPipeline:

Method Mean Allocated
MethodCall 7.513 ns -
GenericPipeline 38.024 ns -
Mediator 79.192 ns -

I'll have to play with this a bit more, might be missing something. Work in progress benchmark is currently on test/mediator-benchmarks branch.

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

No branches or pull requests

2 participants