This document contains benchmarks that are run on consistent desktop hardware as this library is developed.
Naming convention:
<name>_Baseline: simple direct method call into the handler class<name>_Mediator: the concreteMediatorclass generated by this library<name>_IMediator: call through theIMediatorinterface in this library<name>_MediatR: the MediatR library
All benchmarks are parameterized with
- ServiceLifetime (
Transient,Scoped,Singleton) - Project type (small = ~10 messages, large = ~700 messages)
Compares this library to MediatR specifically across a variety of scenarios.
- Initialization - resolve
IMediatorfromIServiceProvider - Cold start - resolve
IMediatorfromIServiceProviderand send a single request using theIRequest<>overload
Does not include comparison to direct handler call (baseline in other benchmarks).
BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.3775)
AMD Ryzen 5 5600X, 1 CPU, 12 logical and 6 physical cores
.NET SDK 8.0.408
[Host] : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Scoped/False : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Scoped/True : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Singleton/False : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Singleton/True : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Transient/False : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Transient/True : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
| Method | Categories | ServiceLifetime | Project type | Mean | Error | StdDev | Median | Ratio | RatioSD | Rank | Gen0 | Allocated | Alloc Ratio |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ColdStart_IMediator | ColdStart | Scoped | Small | 182.497 ns | 2.5872 ns | 2.4201 ns | 181.406 ns | 1.41x faster | 0.04x | 1 | 0.0262 | 440 B | 1.33x less |
| ColdStart_MediatR | ColdStart | Scoped | Small | 256.649 ns | 4.9452 ns | 5.8869 ns | 254.384 ns | baseline | 2 | 0.0348 | 584 B | ||
| ColdStart_MediatR | ColdStart | Scoped | Large | 203.742 ns | 1.5245 ns | 1.4260 ns | 203.090 ns | baseline | 1 | 0.0348 | 584 B | ||
| ColdStart_IMediator | ColdStart | Scoped | Large | 205.762 ns | 2.2596 ns | 2.1136 ns | 205.796 ns | 1.01x slower | 0.01x | 1 | 0.0262 | 440 B | 1.33x less |
| ColdStart_IMediator | ColdStart | Singleton | Small | 21.464 ns | 0.2336 ns | 0.2185 ns | 21.430 ns | 4.76x faster | 0.05x | 1 | - | - | NA |
| ColdStart_MediatR | ColdStart | Singleton | Small | 102.225 ns | 0.4091 ns | 0.3194 ns | 102.170 ns | baseline | 2 | 0.0143 | 240 B | ||
| ColdStart_IMediator | ColdStart | Singleton | Large | 33.109 ns | 0.3034 ns | 0.2838 ns | 32.963 ns | 3.19x faster | 0.03x | 1 | - | - | NA |
| ColdStart_MediatR | ColdStart | Singleton | Large | 105.454 ns | 0.3340 ns | 0.2608 ns | 105.525 ns | baseline | 2 | 0.0143 | 240 B | ||
| ColdStart_IMediator | ColdStart | Transient | Small | 90.174 ns | 1.4549 ns | 1.3610 ns | 90.141 ns | 1.19x faster | 0.02x | 1 | 0.0076 | 128 B | 2.12x less |
| ColdStart_MediatR | ColdStart | Transient | Small | 107.245 ns | 0.7706 ns | 0.7209 ns | 106.961 ns | baseline | 2 | 0.0162 | 272 B | ||
| ColdStart_IMediator | ColdStart | Transient | Large | 99.312 ns | 1.5323 ns | 1.4333 ns | 98.405 ns | 1.21x faster | 0.02x | 1 | 0.0076 | 128 B | 2.12x less |
| ColdStart_MediatR | ColdStart | Transient | Large | 120.515 ns | 0.7521 ns | 0.6667 ns | 120.576 ns | baseline | 2 | 0.0162 | 272 B | ||
| Initialization_IMediator | Initialization | Scoped | Small | 77.527 ns | 0.6315 ns | 0.5274 ns | 77.466 ns | 1.00x faster | 0.01x | 1 | 0.0210 | 352 B | 1.02x more |
| Initialization_MediatR | Initialization | Scoped | Small | 77.845 ns | 1.0981 ns | 1.0272 ns | 77.399 ns | baseline | 1 | 0.0205 | 344 B | ||
| Initialization_IMediator | Initialization | Scoped | Large | 78.882 ns | 0.9058 ns | 0.8472 ns | 79.148 ns | 1.01x faster | 0.01x | 1 | 0.0210 | 352 B | 1.02x more |
| Initialization_MediatR | Initialization | Scoped | Large | 79.430 ns | 0.8772 ns | 0.8205 ns | 79.710 ns | baseline | 1 | 0.0205 | 344 B | ||
| Initialization_MediatR | Initialization | Singleton | Small | 8.427 ns | 0.0682 ns | 0.0533 ns | 8.443 ns | baseline | 1 | - | - | NA | |
| Initialization_IMediator | Initialization | Singleton | Small | 8.703 ns | 0.0856 ns | 0.0801 ns | 8.704 ns | 1.03x slower | 0.01x | 1 | - | - | NA |
| Initialization_MediatR | Initialization | Singleton | Large | 8.649 ns | 0.0761 ns | 0.0711 ns | 8.613 ns | baseline | 1 | - | - | NA | |
| Initialization_IMediator | Initialization | Singleton | Large | 8.955 ns | 0.1028 ns | 0.0961 ns | 8.940 ns | 1.04x slower | 0.01x | 1 | - | - | NA |
| Initialization_IMediator | Initialization | Transient | Small | 12.303 ns | 0.1729 ns | 0.1617 ns | 12.304 ns | 1.05x faster | 0.02x | 1 | 0.0024 | 40 B | 1.25x more |
| Initialization_MediatR | Initialization | Transient | Small | 12.931 ns | 0.2054 ns | 0.1922 ns | 12.971 ns | baseline | 2 | 0.0019 | 32 B | ||
| Initialization_MediatR | Initialization | Transient | Large | 12.618 ns | 0.0242 ns | 0.0202 ns | 12.628 ns | baseline | 1 | 0.0019 | 32 B | ||
| Initialization_IMediator | Initialization | Transient | Large | 13.335 ns | 0.1547 ns | 0.1447 ns | 13.422 ns | 1.06x slower | 0.01x | 2 | 0.0024 | 40 B | 1.25x more |
| Notification_Mediator | Notification,Concrete | Scoped | Small | 45.432 ns | 0.4721 ns | 0.4416 ns | 45.224 ns | 1.84x faster | 0.03x | 1 | - | - | NA |
| Notification_IMediator | Notification,Concrete | Scoped | Small | 50.513 ns | 0.6822 ns | 0.6381 ns | 50.655 ns | 1.65x faster | 0.03x | 2 | - | - | NA |
| Notification_MediatR | Notification,Concrete | Scoped | Small | 83.366 ns | 0.9947 ns | 0.9304 ns | 83.231 ns | baseline | 3 | 0.0172 | 288 B | ||
| Notification_Mediator | Notification,Concrete | Scoped | Large | 57.546 ns | 0.0854 ns | 0.0667 ns | 57.556 ns | 1.58x faster | 0.02x | 1 | - | - | NA |
| Notification_IMediator | Notification,Concrete | Scoped | Large | 64.886 ns | 0.8044 ns | 0.7525 ns | 64.600 ns | 1.40x faster | 0.02x | 2 | - | - | NA |
| Notification_MediatR | Notification,Concrete | Scoped | Large | 90.680 ns | 1.0513 ns | 0.9834 ns | 90.743 ns | baseline | 3 | 0.0172 | 288 B | ||
| Notification_Mediator | Notification,Concrete | Singleton | Small | 12.306 ns | 0.1079 ns | 0.1009 ns | 12.365 ns | 8.91x faster | 0.08x | 1 | - | - | NA |
| Notification_IMediator | Notification,Concrete | Singleton | Small | 16.828 ns | 0.1746 ns | 0.1633 ns | 16.817 ns | 6.52x faster | 0.07x | 2 | - | - | NA |
| Notification_MediatR | Notification,Concrete | Singleton | Small | 109.672 ns | 0.5929 ns | 0.5546 ns | 109.509 ns | baseline | 3 | 0.0172 | 288 B | ||
| Notification_Mediator | Notification,Concrete | Singleton | Large | 12.678 ns | 0.0958 ns | 0.0800 ns | 12.653 ns | 7.02x faster | 0.10x | 1 | - | - | NA |
| Notification_IMediator | Notification,Concrete | Singleton | Large | 25.886 ns | 0.2697 ns | 0.2523 ns | 25.811 ns | 3.44x faster | 0.05x | 2 | - | - | NA |
| Notification_MediatR | Notification,Concrete | Singleton | Large | 89.025 ns | 1.2535 ns | 1.1725 ns | 89.508 ns | baseline | 3 | 0.0172 | 288 B | ||
| Notification_Mediator | Notification,Concrete | Transient | Small | 56.651 ns | 0.5902 ns | 0.5521 ns | 56.814 ns | 1.61x faster | 0.02x | 1 | 0.0033 | 56 B | 5.14x less |
| Notification_IMediator | Notification,Concrete | Transient | Small | 61.682 ns | 0.6987 ns | 0.6536 ns | 61.705 ns | 1.48x faster | 0.02x | 2 | 0.0033 | 56 B | 5.14x less |
| Notification_MediatR | Notification,Concrete | Transient | Small | 91.144 ns | 1.0279 ns | 0.9615 ns | 91.051 ns | baseline | 3 | 0.0172 | 288 B | ||
| Notification_Mediator | Notification,Concrete | Transient | Large | 72.405 ns | 1.1990 ns | 1.1216 ns | 72.358 ns | 1.47x faster | 0.03x | 1 | 0.0033 | 56 B | 5.14x less |
| Notification_IMediator | Notification,Concrete | Transient | Large | 75.957 ns | 0.7581 ns | 0.7091 ns | 75.535 ns | 1.40x faster | 0.02x | 2 | 0.0033 | 56 B | 5.14x less |
| Notification_MediatR | Notification,Concrete | Transient | Large | 106.351 ns | 1.2413 ns | 1.1611 ns | 106.153 ns | baseline | 3 | 0.0172 | 288 B | ||
| Notification_IMediator_Object | Notification,Object | Scoped | Small | 44.494 ns | 0.4836 ns | 0.4524 ns | 44.318 ns | 2.29x faster | 0.04x | 1 | - | - | NA |
| Notification_MediatR_Object | Notification,Object | Scoped | Small | 101.838 ns | 1.4235 ns | 1.3316 ns | 101.194 ns | baseline | 2 | 0.0172 | 288 B | ||
| Notification_IMediator_Object | Notification,Object | Scoped | Large | 57.815 ns | 0.5169 ns | 0.4835 ns | 58.083 ns | 1.46x faster | 0.02x | 1 | - | - | NA |
| Notification_MediatR_Object | Notification,Object | Scoped | Large | 84.322 ns | 0.6173 ns | 0.5774 ns | 84.058 ns | baseline | 2 | 0.0172 | 288 B | ||
| Notification_IMediator_Object | Notification,Object | Singleton | Small | 13.193 ns | 0.1726 ns | 0.1614 ns | 13.178 ns | 6.01x faster | 0.07x | 1 | - | - | NA |
| Notification_MediatR_Object | Notification,Object | Singleton | Small | 79.309 ns | 0.2321 ns | 0.2057 ns | 79.301 ns | baseline | 2 | 0.0172 | 288 B | ||
| Notification_IMediator_Object | Notification,Object | Singleton | Large | 22.005 ns | 0.2232 ns | 0.2088 ns | 21.937 ns | 3.69x faster | 0.06x | 1 | - | - | NA |
| Notification_MediatR_Object | Notification,Object | Singleton | Large | 81.114 ns | 1.0540 ns | 0.9859 ns | 81.068 ns | baseline | 2 | 0.0172 | 288 B | ||
| Notification_IMediator_Object | Notification,Object | Transient | Small | 62.065 ns | 0.8903 ns | 0.8328 ns | 62.599 ns | 1.43x faster | 0.03x | 1 | 0.0033 | 56 B | 5.14x less |
| Notification_MediatR_Object | Notification,Object | Transient | Small | 88.608 ns | 1.3539 ns | 1.2665 ns | 88.004 ns | baseline | 2 | 0.0172 | 288 B | ||
| Notification_IMediator_Object | Notification,Object | Transient | Large | 66.820 ns | 0.9845 ns | 0.9209 ns | 66.366 ns | 1.25x faster | 0.02x | 1 | 0.0033 | 56 B | 5.14x less |
| Notification_MediatR_Object | Notification,Object | Transient | Large | 83.585 ns | 0.9818 ns | 0.7665 ns | 83.880 ns | baseline | 2 | 0.0172 | 288 B | ||
| Request_Mediator | Request,Concrete | Scoped | Small | 59.258 ns | 0.0758 ns | 0.0592 ns | 59.248 ns | 1.55x faster | 0.02x | 1 | 0.0038 | 64 B | 3.75x less |
| Request_IMediator | Request,Concrete | Scoped | Small | 69.451 ns | 1.0378 ns | 0.9708 ns | 69.367 ns | 1.32x faster | 0.02x | 2 | 0.0038 | 64 B | 3.75x less |
| Request_MediatR | Request,Concrete | Scoped | Small | 91.779 ns | 1.3081 ns | 1.2236 ns | 91.653 ns | baseline | 3 | 0.0143 | 240 B | ||
| Request_Mediator | Request,Concrete | Scoped | Large | 69.319 ns | 0.9661 ns | 0.9037 ns | 69.162 ns | 1.49x faster | 0.04x | 1 | 0.0038 | 64 B | 3.75x less |
| Request_IMediator | Request,Concrete | Scoped | Large | 93.343 ns | 1.2152 ns | 1.1367 ns | 93.213 ns | 1.11x faster | 0.03x | 2 | 0.0038 | 64 B | 3.75x less |
| Request_MediatR | Request,Concrete | Scoped | Large | 103.518 ns | 2.0766 ns | 2.6262 ns | 103.559 ns | baseline | 3 | 0.0143 | 240 B | ||
| Request_Mediator | Request,Concrete | Singleton | Small | 2.091 ns | 0.0356 ns | 0.0278 ns | 2.106 ns | 43.88x faster | 0.72x | 1 | - | - | NA |
| Request_IMediator | Request,Concrete | Singleton | Small | 12.593 ns | 0.2094 ns | 0.1959 ns | 12.582 ns | 7.29x faster | 0.13x | 2 | - | - | NA |
| Request_MediatR | Request,Concrete | Singleton | Small | 91.748 ns | 1.0168 ns | 0.9511 ns | 91.636 ns | baseline | 3 | 0.0143 | 240 B | ||
| Request_Mediator | Request,Concrete | Singleton | Large | 4.545 ns | 0.0052 ns | 0.0049 ns | 4.545 ns | 21.80x faster | 0.19x | 1 | - | - | NA |
| Request_IMediator | Request,Concrete | Singleton | Large | 23.841 ns | 0.2726 ns | 0.2550 ns | 23.831 ns | 4.16x faster | 0.06x | 2 | - | - | NA |
| Request_MediatR | Request,Concrete | Singleton | Large | 99.087 ns | 0.9557 ns | 0.8940 ns | 99.637 ns | baseline | 3 | 0.0143 | 240 B | ||
| Request_Mediator | Request,Concrete | Transient | Small | 44.455 ns | 0.5580 ns | 0.5219 ns | 44.361 ns | 2.30x faster | 0.03x | 1 | 0.0052 | 88 B | 2.73x less |
| Request_IMediator | Request,Concrete | Transient | Small | 54.710 ns | 0.5731 ns | 0.5361 ns | 54.463 ns | 1.87x faster | 0.02x | 2 | 0.0052 | 88 B | 2.73x less |
| Request_MediatR | Request,Concrete | Transient | Small | 102.331 ns | 0.2981 ns | 0.2328 ns | 102.364 ns | baseline | 3 | 0.0143 | 240 B | ||
| Request_Mediator | Request,Concrete | Transient | Large | 43.995 ns | 0.6794 ns | 0.6355 ns | 44.022 ns | 2.28x faster | 0.03x | 1 | 0.0052 | 88 B | 2.73x less |
| Request_IMediator | Request,Concrete | Transient | Large | 63.358 ns | 0.7642 ns | 0.7148 ns | 63.265 ns | 1.58x faster | 0.02x | 2 | 0.0052 | 88 B | 2.73x less |
| Request_MediatR | Request,Concrete | Transient | Large | 100.281 ns | 0.3184 ns | 0.2658 ns | 100.350 ns | baseline | 3 | 0.0143 | 240 B | ||
| Request_IMediator_Object | Request,Object | Scoped | Small | 82.444 ns | 0.9427 ns | 0.8818 ns | 82.233 ns | 1.33x faster | 0.02x | 1 | 0.0038 | 64 B | 4.88x less |
| Request_MediatR_Object | Request,Object | Scoped | Small | 109.498 ns | 1.3910 ns | 1.3012 ns | 108.816 ns | baseline | 2 | 0.0186 | 312 B | ||
| Request_IMediator_Object | Request,Object | Scoped | Large | 110.239 ns | 0.8654 ns | 0.8095 ns | 110.703 ns | 1.01x faster | 0.02x | 1 | 0.0038 | 64 B | 4.88x less |
| Request_MediatR_Object | Request,Object | Scoped | Large | 111.629 ns | 1.7231 ns | 1.6118 ns | 111.685 ns | baseline | 1 | 0.0186 | 312 B | ||
| Request_IMediator_Object | Request,Object | Singleton | Small | 17.398 ns | 0.1819 ns | 0.1701 ns | 17.310 ns | 6.32x faster | 0.06x | 1 | - | - | NA |
| Request_MediatR_Object | Request,Object | Singleton | Small | 109.889 ns | 0.2991 ns | 0.2651 ns | 109.793 ns | baseline | 2 | 0.0186 | 312 B | ||
| Request_IMediator_Object | Request,Object | Singleton | Large | 48.037 ns | 0.0878 ns | 0.0685 ns | 48.016 ns | 2.62x faster | 0.03x | 1 | - | - | NA |
| Request_MediatR_Object | Request,Object | Singleton | Large | 125.882 ns | 1.8130 ns | 1.5140 ns | 126.570 ns | baseline | 2 | 0.0186 | 312 B | ||
| Request_IMediator_Object | Request,Object | Transient | Small | 67.150 ns | 0.6297 ns | 0.5890 ns | 66.970 ns | 1.70x faster | 0.02x | 1 | 0.0052 | 88 B | 3.55x less |
| Request_MediatR_Object | Request,Object | Transient | Small | 114.019 ns | 1.5131 ns | 1.4153 ns | 114.502 ns | baseline | 2 | 0.0186 | 312 B | ||
| Request_IMediator_Object | Request,Object | Transient | Large | 92.067 ns | 0.6857 ns | 0.6414 ns | 92.540 ns | 1.17x faster | 0.02x | 1 | 0.0052 | 88 B | 3.55x less |
| Request_MediatR_Object | Request,Object | Transient | Large | 107.835 ns | 1.9923 ns | 1.8636 ns | 106.788 ns | baseline | 2 | 0.0186 | 312 B | ||
| StreamRequest_Mediator | StreamRequest,Concrete | Scoped | Small | 148.902 ns | 1.2537 ns | 1.1727 ns | 148.336 ns | 2.19x faster | 0.02x | 1 | 0.0091 | 152 B | 3.47x less |
| StreamRequest_IMediator | StreamRequest,Concrete | Scoped | Small | 150.262 ns | 0.3164 ns | 0.2642 ns | 150.145 ns | 2.17x faster | 0.01x | 1 | 0.0091 | 152 B | 3.47x less |
| StreamRequest_MediatR | StreamRequest,Concrete | Scoped | Small | 325.586 ns | 0.8436 ns | 0.6586 ns | 325.682 ns | baseline | 2 | 0.0315 | 528 B | ||
| StreamRequest_Mediator | StreamRequest,Concrete | Scoped | Large | 154.899 ns | 1.5809 ns | 1.4787 ns | 154.418 ns | 2.21x faster | 0.03x | 1 | 0.0091 | 152 B | 3.47x less |
| StreamRequest_IMediator | StreamRequest,Concrete | Scoped | Large | 171.930 ns | 0.5838 ns | 0.5461 ns | 172.172 ns | 1.99x faster | 0.02x | 2 | 0.0091 | 152 B | 3.47x less |
| StreamRequest_MediatR | StreamRequest,Concrete | Scoped | Large | 342.480 ns | 3.7124 ns | 3.4726 ns | 340.650 ns | baseline | 3 | 0.0315 | 528 B | ||
| StreamRequest_Mediator | StreamRequest,Concrete | Singleton | Small | 89.165 ns | 0.8095 ns | 0.7572 ns | 88.734 ns | 3.74x faster | 0.06x | 1 | 0.0052 | 88 B | 6.00x less |
| StreamRequest_IMediator | StreamRequest,Concrete | Singleton | Small | 93.405 ns | 1.0071 ns | 0.9421 ns | 92.981 ns | 3.57x faster | 0.06x | 2 | 0.0052 | 88 B | 6.00x less |
| StreamRequest_MediatR | StreamRequest,Concrete | Singleton | Small | 333.733 ns | 4.6877 ns | 4.3849 ns | 333.887 ns | baseline | 3 | 0.0315 | 528 B | ||
| StreamRequest_Mediator | StreamRequest,Concrete | Singleton | Large | 90.182 ns | 0.6587 ns | 0.6161 ns | 89.847 ns | 3.70x faster | 0.05x | 1 | 0.0052 | 88 B | 6.00x less |
| StreamRequest_IMediator | StreamRequest,Concrete | Singleton | Large | 110.232 ns | 1.0520 ns | 0.9840 ns | 110.590 ns | 3.03x faster | 0.04x | 2 | 0.0052 | 88 B | 6.00x less |
| StreamRequest_MediatR | StreamRequest,Concrete | Singleton | Large | 333.911 ns | 3.9332 ns | 3.6791 ns | 331.882 ns | baseline | 3 | 0.0315 | 528 B | ||
| StreamRequest_Mediator | StreamRequest,Concrete | Transient | Small | 135.616 ns | 2.1229 ns | 1.9858 ns | 135.247 ns | 2.41x faster | 0.04x | 1 | 0.0105 | 176 B | 3.00x less |
| StreamRequest_IMediator | StreamRequest,Concrete | Transient | Small | 137.745 ns | 0.4240 ns | 0.3311 ns | 137.776 ns | 2.37x faster | 0.02x | 1 | 0.0105 | 176 B | 3.00x less |
| StreamRequest_MediatR | StreamRequest,Concrete | Transient | Small | 326.920 ns | 3.6046 ns | 3.3717 ns | 325.506 ns | baseline | 2 | 0.0315 | 528 B | ||
| StreamRequest_Mediator | StreamRequest,Concrete | Transient | Large | 149.101 ns | 1.3009 ns | 1.2168 ns | 148.281 ns | 2.21x faster | 0.02x | 1 | 0.0105 | 176 B | 3.00x less |
| StreamRequest_IMediator | StreamRequest,Concrete | Transient | Large | 155.803 ns | 1.8982 ns | 1.7755 ns | 155.736 ns | 2.12x faster | 0.02x | 1 | 0.0105 | 176 B | 3.00x less |
| StreamRequest_MediatR | StreamRequest,Concrete | Transient | Large | 330.115 ns | 0.8829 ns | 0.7373 ns | 330.273 ns | baseline | 2 | 0.0315 | 528 B | ||
| StreamRequest_IMediator_Object | StreamRequest,Object | Scoped | Small | 152.248 ns | 1.2778 ns | 1.1953 ns | 151.641 ns | 2.97x faster | 0.04x | 1 | 0.0091 | 152 B | 4.79x less |
| StreamRequest_MediatR_Object | StreamRequest,Object | Scoped | Small | 451.828 ns | 4.7391 ns | 4.4330 ns | 453.641 ns | baseline | 2 | 0.0434 | 728 B | ||
| StreamRequest_IMediator_Object | StreamRequest,Object | Scoped | Large | 283.295 ns | 3.3448 ns | 3.1287 ns | 285.763 ns | 1.65x faster | 0.03x | 1 | 0.0210 | 352 B | 2.07x less |
| StreamRequest_MediatR_Object | StreamRequest,Object | Scoped | Large | 466.648 ns | 6.1358 ns | 5.7394 ns | 466.418 ns | baseline | 2 | 0.0434 | 728 B | ||
| StreamRequest_IMediator_Object | StreamRequest,Object | Singleton | Small | 89.333 ns | 1.1532 ns | 1.0787 ns | 89.155 ns | 4.99x faster | 0.07x | 1 | 0.0052 | 88 B | 8.27x less |
| StreamRequest_MediatR_Object | StreamRequest,Object | Singleton | Small | 445.828 ns | 4.3816 ns | 4.0985 ns | 443.209 ns | baseline | 2 | 0.0434 | 728 B | ||
| StreamRequest_IMediator_Object | StreamRequest,Object | Singleton | Large | 210.370 ns | 2.0411 ns | 1.9093 ns | 211.188 ns | 2.17x faster | 0.04x | 1 | 0.0162 | 272 B | 2.68x less |
| StreamRequest_MediatR_Object | StreamRequest,Object | Singleton | Large | 456.542 ns | 7.3446 ns | 6.8702 ns | 451.907 ns | baseline | 2 | 0.0434 | 728 B | ||
| StreamRequest_IMediator_Object | StreamRequest,Object | Transient | Small | 138.267 ns | 1.9290 ns | 1.8044 ns | 137.245 ns | 3.32x faster | 0.06x | 1 | 0.0105 | 176 B | 4.14x less |
| StreamRequest_MediatR_Object | StreamRequest,Object | Transient | Small | 459.606 ns | 5.6478 ns | 5.2830 ns | 456.771 ns | baseline | 2 | 0.0434 | 728 B | ||
| StreamRequest_IMediator_Object | StreamRequest,Object | Transient | Large | 260.530 ns | 3.4777 ns | 3.2531 ns | 260.462 ns | 1.74x faster | 0.02x | 1 | 0.0224 | 376 B | 1.94x less |
| StreamRequest_MediatR_Object | StreamRequest,Object | Transient | Large | 452.623 ns | 1.7500 ns | 1.3663 ns | 452.602 ns | baseline | 2 | 0.0434 | 728 B |
BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.3775)
AMD Ryzen 5 5600X, 1 CPU, 12 logical and 6 physical cores
.NET SDK 8.0.408
[Host] : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Scoped/False : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Scoped/True : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Singleton/False : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Singleton/True : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Transient/False : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Transient/True : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
| Method | ServiceLifetime | Project type | Mean | Error | StdDev | Ratio | RatioSD | Rank | Gen0 | Allocated | Alloc Ratio |
|---|---|---|---|---|---|---|---|---|---|---|---|
| SendRequest_Baseline | Scoped | Small | 0.6981 ns | 0.0360 ns | 0.0319 ns | baseline | 1 | - | - | NA | |
| SendRequest_Mediator | Scoped | Small | 59.1317 ns | 0.8285 ns | 0.7749 ns | 84.87x slower | 3.95x | 2 | 0.0038 | 64 B | NA |
| SendRequest_IMediator | Scoped | Small | 67.8432 ns | 0.6172 ns | 0.5773 ns | 97.38x slower | 4.43x | 3 | 0.0038 | 64 B | NA |
| SendRequest_MediatR | Scoped | Small | 92.2899 ns | 1.8752 ns | 2.9743 ns | 132.47x slower | 7.26x | 4 | 0.0143 | 240 B | NA |
| SendRequest_Baseline | Scoped | Large | 0.8265 ns | 0.0309 ns | 0.0289 ns | baseline | 1 | - | - | NA | |
| SendRequest_Mediator | Scoped | Large | 62.1197 ns | 0.9575 ns | 0.8957 ns | 75.24x slower | 2.71x | 2 | 0.0038 | 64 B | NA |
| SendRequest_IMediator | Scoped | Large | 84.9915 ns | 0.9094 ns | 0.8507 ns | 102.94x slower | 3.56x | 3 | 0.0038 | 64 B | NA |
| SendRequest_MediatR | Scoped | Large | 95.4330 ns | 1.3768 ns | 1.2878 ns | 115.59x slower | 4.13x | 4 | 0.0143 | 240 B | NA |
| SendRequest_Baseline | Singleton | Small | 0.6845 ns | 0.0304 ns | 0.0285 ns | baseline | 1 | - | - | NA | |
| SendRequest_Mediator | Singleton | Small | 2.1552 ns | 0.0544 ns | 0.0509 ns | 3.15x slower | 0.15x | 2 | - | - | NA |
| SendRequest_IMediator | Singleton | Small | 11.4761 ns | 0.1480 ns | 0.1384 ns | 16.79x slower | 0.72x | 3 | - | - | NA |
| SendRequest_MediatR | Singleton | Small | 89.3342 ns | 0.9817 ns | 0.9183 ns | 130.73x slower | 5.52x | 4 | 0.0143 | 240 B | NA |
| SendRequest_Baseline | Singleton | Large | 0.8382 ns | 0.0198 ns | 0.0154 ns | baseline | 1 | - | - | NA | |
| SendRequest_Mediator | Singleton | Large | 4.3344 ns | 0.0053 ns | 0.0050 ns | 5.17x slower | 0.09x | 2 | - | - | NA |
| SendRequest_IMediator | Singleton | Large | 23.3037 ns | 0.1319 ns | 0.1101 ns | 27.81x slower | 0.51x | 3 | - | - | NA |
| SendRequest_MediatR | Singleton | Large | 94.3976 ns | 0.8197 ns | 0.7668 ns | 112.65x slower | 2.20x | 4 | 0.0143 | 240 B | NA |
| SendRequest_Baseline | Transient | Small | 0.6777 ns | 0.0038 ns | 0.0032 ns | baseline | 1 | - | - | NA | |
| SendRequest_Mediator | Transient | Small | 45.5980 ns | 0.9322 ns | 1.1097 ns | 67.29x slower | 1.63x | 2 | 0.0052 | 88 B | NA |
| SendRequest_IMediator | Transient | Small | 53.7563 ns | 0.6740 ns | 0.6304 ns | 79.33x slower | 0.97x | 3 | 0.0052 | 88 B | NA |
| SendRequest_MediatR | Transient | Small | 89.1215 ns | 0.3485 ns | 0.2910 ns | 131.52x slower | 0.72x | 4 | 0.0143 | 240 B | NA |
| SendRequest_Baseline | Transient | Large | 0.8872 ns | 0.0379 ns | 0.0355 ns | baseline | 1 | - | - | NA | |
| SendRequest_Mediator | Transient | Large | 49.3186 ns | 1.0209 ns | 1.2911 ns | 55.67x slower | 2.54x | 2 | 0.0052 | 88 B | NA |
| SendRequest_IMediator | Transient | Large | 80.3574 ns | 0.7423 ns | 0.6943 ns | 90.71x slower | 3.50x | 3 | 0.0052 | 88 B | NA |
| SendRequest_MediatR | Transient | Large | 103.0883 ns | 1.5314 ns | 1.4325 ns | 116.36x slower | 4.66x | 4 | 0.0143 | 240 B | NA |
BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.3775)
AMD Ryzen 5 5600X, 1 CPU, 12 logical and 6 physical cores
.NET SDK 8.0.408
[Host] : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Scoped/ForeachAwait/False : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Scoped/ForeachAwait/True : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Scoped/TaskWhenAll/False : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Scoped/TaskWhenAll/True : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Singleton/ForeachAwait/False : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Singleton/ForeachAwait/True : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Singleton/TaskWhenAll/False : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Singleton/TaskWhenAll/True : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Transient/ForeachAwait/False : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Transient/ForeachAwait/True : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Transient/TaskWhenAll/False : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Transient/TaskWhenAll/True : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
| Method | Scenario | ServiceLifetime | NotificationPublisher | Project type | Mean | Error | StdDev | Median | Ratio | RatioSD | Rank | Gen0 | Allocated | Alloc Ratio |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Publish_Notification_Baseline | SingleHandlerSync | Scoped | ForeachAwait | Small | 7.305 ns | 0.1017 ns | 0.0951 ns | 7.251 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | SingleHandlerSync | Scoped | ForeachAwait | Small | 48.001 ns | 0.8086 ns | 0.7564 ns | 47.896 ns | 6.57x slower | 0.13x | 2 | - | - | NA |
| Publish_Notification_IMediator | SingleHandlerSync | Scoped | ForeachAwait | Small | 54.616 ns | 0.6510 ns | 0.6089 ns | 54.352 ns | 7.48x slower | 0.12x | 3 | - | - | NA |
| Publish_Notification_MediatR | SingleHandlerSync | Scoped | ForeachAwait | Small | 93.706 ns | 1.1838 ns | 1.1073 ns | 94.268 ns | 12.83x slower | 0.22x | 4 | 0.0172 | 288 B | NA |
| Publish_Notification_Baseline | SingleHandlerSync | Scoped | ForeachAwait | Large | 8.443 ns | 0.1293 ns | 0.1210 ns | 8.378 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | SingleHandlerSync | Scoped | ForeachAwait | Large | 58.017 ns | 0.0857 ns | 0.0801 ns | 57.997 ns | 6.87x slower | 0.09x | 2 | - | - | NA |
| Publish_Notification_IMediator | SingleHandlerSync | Scoped | ForeachAwait | Large | 64.882 ns | 0.0756 ns | 0.0670 ns | 64.873 ns | 7.69x slower | 0.11x | 3 | - | - | NA |
| Publish_Notification_MediatR | SingleHandlerSync | Scoped | ForeachAwait | Large | 87.541 ns | 0.9963 ns | 0.9319 ns | 88.076 ns | 10.37x slower | 0.18x | 4 | 0.0172 | 288 B | NA |
| Publish_Notification_Baseline | SingleHandlerSync | Scoped | TaskWhenAll | Small | 7.371 ns | 0.1203 ns | 0.1125 ns | 7.456 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | SingleHandlerSync | Scoped | TaskWhenAll | Small | 45.582 ns | 0.4035 ns | 0.3150 ns | 45.497 ns | 6.19x slower | 0.10x | 2 | - | - | NA |
| Publish_Notification_IMediator | SingleHandlerSync | Scoped | TaskWhenAll | Small | 57.228 ns | 0.9063 ns | 0.8477 ns | 56.535 ns | 7.77x slower | 0.16x | 3 | - | - | NA |
| Publish_Notification_MediatR | SingleHandlerSync | Scoped | TaskWhenAll | Small | 87.690 ns | 0.9378 ns | 0.8772 ns | 87.361 ns | 11.90x slower | 0.21x | 4 | 0.0172 | 288 B | NA |
| Publish_Notification_Baseline | SingleHandlerSync | Scoped | TaskWhenAll | Large | 7.341 ns | 0.1203 ns | 0.1125 ns | 7.427 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | SingleHandlerSync | Scoped | TaskWhenAll | Large | 59.247 ns | 0.7027 ns | 0.6573 ns | 59.632 ns | 8.07x slower | 0.15x | 2 | - | - | NA |
| Publish_Notification_IMediator | SingleHandlerSync | Scoped | TaskWhenAll | Large | 67.162 ns | 0.9356 ns | 0.8751 ns | 66.641 ns | 9.15x slower | 0.18x | 3 | - | - | NA |
| Publish_Notification_MediatR | SingleHandlerSync | Scoped | TaskWhenAll | Large | 87.184 ns | 0.9138 ns | 0.8547 ns | 86.902 ns | 11.88x slower | 0.21x | 4 | 0.0172 | 288 B | NA |
| Publish_Notification_Baseline | SingleHandlerSync | Singleton | ForeachAwait | Small | 7.467 ns | 0.0063 ns | 0.0049 ns | 7.467 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | SingleHandlerSync | Singleton | ForeachAwait | Small | 14.682 ns | 0.1814 ns | 0.1697 ns | 14.603 ns | 1.97x slower | 0.02x | 2 | - | - | NA |
| Publish_Notification_IMediator | SingleHandlerSync | Singleton | ForeachAwait | Small | 18.116 ns | 0.1526 ns | 0.1427 ns | 18.042 ns | 2.43x slower | 0.02x | 3 | - | - | NA |
| Publish_Notification_MediatR | SingleHandlerSync | Singleton | ForeachAwait | Small | 87.571 ns | 1.7179 ns | 1.6872 ns | 86.718 ns | 11.73x slower | 0.22x | 4 | 0.0172 | 288 B | NA |
| Publish_Notification_Baseline | SingleHandlerSync | Singleton | ForeachAwait | Large | 7.330 ns | 0.1290 ns | 0.1207 ns | 7.231 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | SingleHandlerSync | Singleton | ForeachAwait | Large | 16.195 ns | 0.1891 ns | 0.1769 ns | 16.054 ns | 2.21x slower | 0.04x | 2 | - | - | NA |
| Publish_Notification_IMediator | SingleHandlerSync | Singleton | ForeachAwait | Large | 30.843 ns | 0.2375 ns | 0.1983 ns | 30.740 ns | 4.21x slower | 0.07x | 3 | - | - | NA |
| Publish_Notification_MediatR | SingleHandlerSync | Singleton | ForeachAwait | Large | 86.646 ns | 0.9101 ns | 0.8513 ns | 86.976 ns | 11.82x slower | 0.22x | 4 | 0.0172 | 288 B | NA |
| Publish_Notification_Baseline | SingleHandlerSync | Singleton | TaskWhenAll | Small | 7.386 ns | 0.1112 ns | 0.1040 ns | 7.461 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | SingleHandlerSync | Singleton | TaskWhenAll | Small | 14.983 ns | 0.0186 ns | 0.0145 ns | 14.983 ns | 2.03x slower | 0.03x | 2 | - | - | NA |
| Publish_Notification_IMediator | SingleHandlerSync | Singleton | TaskWhenAll | Small | 19.043 ns | 0.2134 ns | 0.1997 ns | 18.926 ns | 2.58x slower | 0.04x | 3 | - | - | NA |
| Publish_Notification_MediatR | SingleHandlerSync | Singleton | TaskWhenAll | Small | 86.530 ns | 1.2116 ns | 1.1333 ns | 86.420 ns | 11.72x slower | 0.22x | 4 | 0.0172 | 288 B | NA |
| Publish_Notification_Baseline | SingleHandlerSync | Singleton | TaskWhenAll | Large | 7.542 ns | 0.1142 ns | 0.1068 ns | 7.479 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | SingleHandlerSync | Singleton | TaskWhenAll | Large | 16.899 ns | 0.1462 ns | 0.1367 ns | 16.834 ns | 2.24x slower | 0.04x | 2 | - | - | NA |
| Publish_Notification_IMediator | SingleHandlerSync | Singleton | TaskWhenAll | Large | 30.736 ns | 0.0569 ns | 0.0444 ns | 30.737 ns | 4.08x slower | 0.06x | 3 | - | - | NA |
| Publish_Notification_MediatR | SingleHandlerSync | Singleton | TaskWhenAll | Large | 102.222 ns | 0.9934 ns | 0.9293 ns | 102.166 ns | 13.56x slower | 0.22x | 4 | 0.0172 | 288 B | NA |
| Publish_Notification_Baseline | SingleHandlerSync | Transient | ForeachAwait | Small | 7.248 ns | 0.0140 ns | 0.0131 ns | 7.242 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | SingleHandlerSync | Transient | ForeachAwait | Small | 54.226 ns | 1.0196 ns | 0.9537 ns | 53.618 ns | 7.48x slower | 0.13x | 2 | 0.0033 | 56 B | NA |
| Publish_Notification_IMediator | SingleHandlerSync | Transient | ForeachAwait | Small | 58.864 ns | 0.2144 ns | 0.1901 ns | 58.822 ns | 8.12x slower | 0.03x | 3 | 0.0033 | 56 B | NA |
| Publish_Notification_MediatR | SingleHandlerSync | Transient | ForeachAwait | Small | 89.090 ns | 0.1972 ns | 0.1646 ns | 89.029 ns | 12.29x slower | 0.03x | 4 | 0.0172 | 288 B | NA |
| Publish_Notification_Baseline | SingleHandlerSync | Transient | ForeachAwait | Large | 7.231 ns | 0.0085 ns | 0.0066 ns | 7.233 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | SingleHandlerSync | Transient | ForeachAwait | Large | 67.494 ns | 0.0998 ns | 0.0885 ns | 67.478 ns | 9.33x slower | 0.01x | 2 | 0.0033 | 56 B | NA |
| Publish_Notification_IMediator | SingleHandlerSync | Transient | ForeachAwait | Large | 75.528 ns | 0.9140 ns | 0.8549 ns | 75.303 ns | 10.45x slower | 0.11x | 3 | 0.0033 | 56 B | NA |
| Publish_Notification_MediatR | SingleHandlerSync | Transient | ForeachAwait | Large | 91.516 ns | 0.9592 ns | 0.8973 ns | 92.166 ns | 12.66x slower | 0.12x | 4 | 0.0172 | 288 B | NA |
| Publish_Notification_Baseline | SingleHandlerSync | Transient | TaskWhenAll | Small | 7.534 ns | 0.1159 ns | 0.1084 ns | 7.457 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | SingleHandlerSync | Transient | TaskWhenAll | Small | 52.938 ns | 0.3778 ns | 0.3534 ns | 52.760 ns | 7.03x slower | 0.11x | 2 | 0.0033 | 56 B | NA |
| Publish_Notification_IMediator | SingleHandlerSync | Transient | TaskWhenAll | Small | 62.067 ns | 0.6694 ns | 0.6261 ns | 61.902 ns | 8.24x slower | 0.14x | 3 | 0.0033 | 56 B | NA |
| Publish_Notification_MediatR | SingleHandlerSync | Transient | TaskWhenAll | Small | 87.497 ns | 1.1407 ns | 1.0670 ns | 88.185 ns | 11.62x slower | 0.21x | 4 | 0.0172 | 288 B | NA |
| Publish_Notification_Baseline | SingleHandlerSync | Transient | TaskWhenAll | Large | 7.246 ns | 0.0240 ns | 0.0225 ns | 7.241 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | SingleHandlerSync | Transient | TaskWhenAll | Large | 64.716 ns | 0.1337 ns | 0.1185 ns | 64.669 ns | 8.93x slower | 0.03x | 2 | 0.0033 | 56 B | NA |
| Publish_Notification_IMediator | SingleHandlerSync | Transient | TaskWhenAll | Large | 75.160 ns | 0.9397 ns | 0.8790 ns | 75.267 ns | 10.37x slower | 0.12x | 3 | 0.0033 | 56 B | NA |
| Publish_Notification_MediatR | SingleHandlerSync | Transient | TaskWhenAll | Large | 87.441 ns | 0.7601 ns | 0.7110 ns | 87.950 ns | 12.07x slower | 0.10x | 4 | 0.0172 | 288 B | NA |
| Publish_Notification_Baseline | MultiHandlersSync | Scoped | ForeachAwait | Small | 6.956 ns | 0.0087 ns | 0.0082 ns | 6.954 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | MultiHandlersSync | Scoped | ForeachAwait | Small | 50.251 ns | 0.5134 ns | 0.4802 ns | 50.635 ns | 7.22x slower | 0.07x | 2 | - | - | NA |
| Publish_Notification_IMediator | MultiHandlersSync | Scoped | ForeachAwait | Small | 54.916 ns | 0.5922 ns | 0.5540 ns | 54.750 ns | 7.89x slower | 0.08x | 3 | - | - | NA |
| Publish_Notification_MediatR | MultiHandlersSync | Scoped | ForeachAwait | Small | 141.547 ns | 1.6027 ns | 1.4992 ns | 142.409 ns | 20.35x slower | 0.21x | 4 | 0.0353 | 592 B | NA |
| Publish_Notification_Baseline | MultiHandlersSync | Scoped | ForeachAwait | Large | 7.023 ns | 0.1124 ns | 0.1051 ns | 6.960 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | MultiHandlersSync | Scoped | ForeachAwait | Large | 62.118 ns | 0.7257 ns | 0.6789 ns | 62.610 ns | 8.85x slower | 0.16x | 2 | - | - | NA |
| Publish_Notification_IMediator | MultiHandlersSync | Scoped | ForeachAwait | Large | 68.120 ns | 0.6953 ns | 0.6503 ns | 67.692 ns | 9.70x slower | 0.17x | 3 | - | - | NA |
| Publish_Notification_MediatR | MultiHandlersSync | Scoped | ForeachAwait | Large | 160.565 ns | 2.5100 ns | 2.3479 ns | 159.687 ns | 22.87x slower | 0.46x | 4 | 0.0353 | 592 B | NA |
| Publish_Notification_Baseline | MultiHandlersSync | Scoped | TaskWhenAll | Small | 7.126 ns | 0.1171 ns | 0.1096 ns | 7.189 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | MultiHandlersSync | Scoped | TaskWhenAll | Small | 50.318 ns | 0.5249 ns | 0.4910 ns | 50.002 ns | 7.06x slower | 0.12x | 2 | - | - | NA |
| Publish_Notification_IMediator | MultiHandlersSync | Scoped | TaskWhenAll | Small | 56.241 ns | 0.9910 ns | 0.9270 ns | 55.777 ns | 7.89x slower | 0.17x | 3 | - | - | NA |
| Publish_Notification_MediatR | MultiHandlersSync | Scoped | TaskWhenAll | Small | 136.409 ns | 2.6986 ns | 2.5243 ns | 135.232 ns | 19.15x slower | 0.45x | 4 | 0.0353 | 592 B | NA |
| Publish_Notification_Baseline | MultiHandlersSync | Scoped | TaskWhenAll | Large | 6.727 ns | 0.1078 ns | 0.1008 ns | 6.660 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | MultiHandlersSync | Scoped | TaskWhenAll | Large | 68.484 ns | 0.4646 ns | 0.3880 ns | 68.699 ns | 10.18x slower | 0.16x | 2 | - | - | NA |
| Publish_Notification_IMediator | MultiHandlersSync | Scoped | TaskWhenAll | Large | 69.666 ns | 0.6765 ns | 0.6328 ns | 70.166 ns | 10.36x slower | 0.17x | 2 | - | - | NA |
| Publish_Notification_MediatR | MultiHandlersSync | Scoped | TaskWhenAll | Large | 149.647 ns | 1.7746 ns | 1.6600 ns | 149.078 ns | 22.25x slower | 0.40x | 3 | 0.0353 | 592 B | NA |
| Publish_Notification_Baseline | MultiHandlersSync | Singleton | ForeachAwait | Small | 6.643 ns | 0.0105 ns | 0.0082 ns | 6.640 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | MultiHandlersSync | Singleton | ForeachAwait | Small | 18.056 ns | 0.1880 ns | 0.1759 ns | 17.999 ns | 2.72x slower | 0.03x | 2 | - | - | NA |
| Publish_Notification_IMediator | MultiHandlersSync | Singleton | ForeachAwait | Small | 24.050 ns | 0.3015 ns | 0.2820 ns | 24.032 ns | 3.62x slower | 0.04x | 3 | - | - | NA |
| Publish_Notification_MediatR | MultiHandlersSync | Singleton | ForeachAwait | Small | 181.362 ns | 0.9346 ns | 0.8742 ns | 181.128 ns | 27.30x slower | 0.13x | 4 | 0.0353 | 592 B | NA |
| Publish_Notification_Baseline | MultiHandlersSync | Singleton | ForeachAwait | Large | 6.766 ns | 0.1133 ns | 0.1060 ns | 6.683 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | MultiHandlersSync | Singleton | ForeachAwait | Large | 19.285 ns | 0.0209 ns | 0.0175 ns | 19.288 ns | 2.85x slower | 0.04x | 2 | - | - | NA |
| Publish_Notification_IMediator | MultiHandlersSync | Singleton | ForeachAwait | Large | 34.136 ns | 0.4930 ns | 0.4612 ns | 33.958 ns | 5.05x slower | 0.10x | 3 | - | - | NA |
| Publish_Notification_MediatR | MultiHandlersSync | Singleton | ForeachAwait | Large | 181.660 ns | 2.2391 ns | 2.0945 ns | 182.740 ns | 26.85x slower | 0.50x | 4 | 0.0353 | 592 B | NA |
| Publish_Notification_Baseline | MultiHandlersSync | Singleton | TaskWhenAll | Small | 7.121 ns | 0.1189 ns | 0.1113 ns | 7.209 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | MultiHandlersSync | Singleton | TaskWhenAll | Small | 17.373 ns | 0.1970 ns | 0.1843 ns | 17.405 ns | 2.44x slower | 0.04x | 2 | - | - | NA |
| Publish_Notification_IMediator | MultiHandlersSync | Singleton | TaskWhenAll | Small | 24.852 ns | 0.3209 ns | 0.3002 ns | 24.924 ns | 3.49x slower | 0.07x | 3 | - | - | NA |
| Publish_Notification_MediatR | MultiHandlersSync | Singleton | TaskWhenAll | Small | 138.806 ns | 1.9621 ns | 1.8354 ns | 138.193 ns | 19.50x slower | 0.39x | 4 | 0.0353 | 592 B | NA |
| Publish_Notification_Baseline | MultiHandlersSync | Singleton | TaskWhenAll | Large | 7.445 ns | 0.0162 ns | 0.0135 ns | 7.450 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | MultiHandlersSync | Singleton | TaskWhenAll | Large | 18.284 ns | 0.0216 ns | 0.0180 ns | 18.275 ns | 2.46x slower | 0.00x | 2 | - | - | NA |
| Publish_Notification_IMediator | MultiHandlersSync | Singleton | TaskWhenAll | Large | 34.785 ns | 0.4378 ns | 0.4095 ns | 34.763 ns | 4.67x slower | 0.05x | 3 | - | - | NA |
| Publish_Notification_MediatR | MultiHandlersSync | Singleton | TaskWhenAll | Large | 197.717 ns | 2.8380 ns | 2.6547 ns | 196.325 ns | 26.56x slower | 0.35x | 4 | 0.0353 | 592 B | NA |
| Publish_Notification_Baseline | MultiHandlersSync | Transient | ForeachAwait | Small | 6.755 ns | 0.1079 ns | 0.1009 ns | 6.703 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | MultiHandlersSync | Transient | ForeachAwait | Small | 148.010 ns | 2.0268 ns | 1.8959 ns | 147.099 ns | 21.92x slower | 0.42x | 2 | 0.0072 | 120 B | NA |
| Publish_Notification_IMediator | MultiHandlersSync | Transient | ForeachAwait | Small | 152.176 ns | 1.6868 ns | 1.5778 ns | 152.224 ns | 22.53x slower | 0.39x | 2 | 0.0072 | 120 B | NA |
| Publish_Notification_MediatR | MultiHandlersSync | Transient | ForeachAwait | Small | 183.120 ns | 2.8018 ns | 2.6208 ns | 182.043 ns | 27.12x slower | 0.54x | 3 | 0.0353 | 592 B | NA |
| Publish_Notification_Baseline | MultiHandlersSync | Transient | ForeachAwait | Large | 6.806 ns | 0.1060 ns | 0.0992 ns | 6.881 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_MediatR | MultiHandlersSync | Transient | ForeachAwait | Large | 145.327 ns | 1.8746 ns | 1.7535 ns | 146.411 ns | 21.36x slower | 0.39x | 2 | 0.0353 | 592 B | NA |
| Publish_Notification_Mediator | MultiHandlersSync | Transient | ForeachAwait | Large | 164.156 ns | 1.0922 ns | 1.0216 ns | 163.394 ns | 24.12x slower | 0.37x | 3 | 0.0072 | 120 B | NA |
| Publish_Notification_IMediator | MultiHandlersSync | Transient | ForeachAwait | Large | 164.801 ns | 0.0822 ns | 0.0642 ns | 164.782 ns | 24.22x slower | 0.34x | 3 | 0.0072 | 120 B | NA |
| Publish_Notification_Baseline | MultiHandlersSync | Transient | TaskWhenAll | Small | 6.735 ns | 0.1133 ns | 0.1060 ns | 6.663 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_Mediator | MultiHandlersSync | Transient | TaskWhenAll | Small | 145.056 ns | 2.1155 ns | 1.9788 ns | 144.081 ns | 21.54x slower | 0.43x | 2 | 0.0072 | 120 B | NA |
| Publish_Notification_MediatR | MultiHandlersSync | Transient | TaskWhenAll | Small | 156.291 ns | 2.2404 ns | 2.0957 ns | 155.175 ns | 23.21x slower | 0.46x | 3 | 0.0353 | 592 B | NA |
| Publish_Notification_IMediator | MultiHandlersSync | Transient | TaskWhenAll | Small | 164.463 ns | 2.0268 ns | 1.8959 ns | 163.764 ns | 24.42x slower | 0.46x | 4 | 0.0072 | 120 B | NA |
| Publish_Notification_Baseline | MultiHandlersSync | Transient | TaskWhenAll | Large | 6.665 ns | 0.0041 ns | 0.0034 ns | 6.665 ns | baseline | 1 | - | - | NA | |
| Publish_Notification_MediatR | MultiHandlersSync | Transient | TaskWhenAll | Large | 134.750 ns | 1.0166 ns | 0.9509 ns | 134.449 ns | 20.22x slower | 0.14x | 2 | 0.0353 | 592 B | NA |
| Publish_Notification_IMediator | MultiHandlersSync | Transient | TaskWhenAll | Large | 168.887 ns | 2.0423 ns | 1.9104 ns | 167.870 ns | 25.34x slower | 0.28x | 3 | 0.0072 | 120 B | NA |
| Publish_Notification_Mediator | MultiHandlersSync | Transient | TaskWhenAll | Large | 170.440 ns | 1.9916 ns | 1.8629 ns | 169.559 ns | 25.57x slower | 0.27x | 3 | 0.0072 | 120 B | NA |
| Publish_Notification_Baseline | MultiHandlersAsync | Scoped | ForeachAwait | Small | 1,354.528 ns | 9.4207 ns | 8.8121 ns | 1,353.903 ns | baseline | 1 | 0.0229 | 400 B | ||
| Publish_Notification_Mediator | MultiHandlersAsync | Scoped | ForeachAwait | Small | 1,427.414 ns | 9.3329 ns | 8.7300 ns | 1,427.854 ns | 1.05x slower | 0.01x | 2 | 0.0267 | 448 B | 1.12x more |
| Publish_Notification_IMediator | MultiHandlersAsync | Scoped | ForeachAwait | Small | 1,453.941 ns | 5.2751 ns | 4.9344 ns | 1,454.089 ns | 1.07x slower | 0.01x | 2 | 0.0267 | 448 B | 1.12x more |
| Publish_Notification_MediatR | MultiHandlersAsync | Scoped | ForeachAwait | Small | 1,468.739 ns | 5.5614 ns | 5.2021 ns | 1,468.785 ns | 1.08x slower | 0.01x | 2 | 0.0610 | 1016 B | 2.54x more |
| Publish_Notification_Baseline | MultiHandlersAsync | Scoped | ForeachAwait | Large | 1,379.052 ns | 7.6385 ns | 7.1451 ns | 1,377.399 ns | baseline | 1 | 0.0229 | 400 B | ||
| Publish_Notification_MediatR | MultiHandlersAsync | Scoped | ForeachAwait | Large | 1,450.151 ns | 6.2894 ns | 5.8831 ns | 1,451.570 ns | 1.05x slower | 0.01x | 2 | 0.0610 | 1016 B | 2.54x more |
| Publish_Notification_IMediator | MultiHandlersAsync | Scoped | ForeachAwait | Large | 1,474.969 ns | 10.1176 ns | 8.9690 ns | 1,471.535 ns | 1.07x slower | 0.01x | 2 | 0.0267 | 448 B | 1.12x more |
| Publish_Notification_Mediator | MultiHandlersAsync | Scoped | ForeachAwait | Large | 1,475.282 ns | 8.2515 ns | 7.7185 ns | 1,475.982 ns | 1.07x slower | 0.01x | 2 | 0.0267 | 448 B | 1.12x more |
| Publish_Notification_Mediator | MultiHandlersAsync | Scoped | TaskWhenAll | Small | 1,101.589 ns | 4.7438 ns | 3.9613 ns | 1,101.849 ns | 1.25x faster | 0.01x | 1 | 0.0229 | 390 B | 1.03x less |
| Publish_Notification_IMediator | MultiHandlersAsync | Scoped | TaskWhenAll | Small | 1,108.025 ns | 4.6349 ns | 3.8703 ns | 1,108.218 ns | 1.24x faster | 0.01x | 1 | 0.0229 | 388 B | 1.03x less |
| Publish_Notification_Baseline | MultiHandlersAsync | Scoped | TaskWhenAll | Small | 1,376.899 ns | 12.4064 ns | 10.9979 ns | 1,374.960 ns | baseline | 2 | 0.0229 | 400 B | ||
| Publish_Notification_MediatR | MultiHandlersAsync | Scoped | TaskWhenAll | Small | 1,475.407 ns | 6.1746 ns | 5.7758 ns | 1,475.050 ns | 1.07x slower | 0.01x | 3 | 0.0610 | 1016 B | 2.54x more |
| Publish_Notification_Mediator | MultiHandlersAsync | Scoped | TaskWhenAll | Large | 1,100.920 ns | 6.8553 ns | 5.7245 ns | 1,099.851 ns | 1.24x faster | 0.01x | 1 | 0.0229 | 391 B | 1.02x less |
| Publish_Notification_IMediator | MultiHandlersAsync | Scoped | TaskWhenAll | Large | 1,114.367 ns | 5.8687 ns | 5.4896 ns | 1,113.742 ns | 1.22x faster | 0.01x | 1 | 0.0229 | 387 B | 1.03x less |
| Publish_Notification_Baseline | MultiHandlersAsync | Scoped | TaskWhenAll | Large | 1,363.987 ns | 3.9884 ns | 3.5356 ns | 1,363.462 ns | baseline | 2 | 0.0229 | 400 B | ||
| Publish_Notification_MediatR | MultiHandlersAsync | Scoped | TaskWhenAll | Large | 1,489.596 ns | 6.8064 ns | 6.3667 ns | 1,490.541 ns | 1.09x slower | 0.01x | 3 | 0.0610 | 1016 B | 2.54x more |
| Publish_Notification_Baseline | MultiHandlersAsync | Singleton | ForeachAwait | Small | 1,350.982 ns | 6.6985 ns | 5.9380 ns | 1,350.484 ns | baseline | 1 | 0.0229 | 400 B | ||
| Publish_Notification_IMediator | MultiHandlersAsync | Singleton | ForeachAwait | Small | 1,431.380 ns | 8.8678 ns | 8.2949 ns | 1,434.044 ns | 1.06x slower | 0.01x | 2 | 0.0267 | 448 B | 1.12x more |
| Publish_Notification_MediatR | MultiHandlersAsync | Singleton | ForeachAwait | Small | 1,459.801 ns | 5.0341 ns | 4.4626 ns | 1,459.906 ns | 1.08x slower | 0.01x | 2 | 0.0610 | 1016 B | 2.54x more |
| Publish_Notification_Mediator | MultiHandlersAsync | Singleton | ForeachAwait | Small | 1,488.810 ns | 5.5894 ns | 4.9548 ns | 1,488.764 ns | 1.10x slower | 0.01x | 2 | 0.0267 | 448 B | 1.12x more |
| Publish_Notification_Baseline | MultiHandlersAsync | Singleton | ForeachAwait | Large | 1,357.382 ns | 8.6725 ns | 8.1123 ns | 1,357.972 ns | baseline | 1 | 0.0229 | 400 B | ||
| Publish_Notification_MediatR | MultiHandlersAsync | Singleton | ForeachAwait | Large | 1,432.556 ns | 9.5850 ns | 8.9659 ns | 1,431.358 ns | 1.06x slower | 0.01x | 2 | 0.0610 | 1016 B | 2.54x more |
| Publish_Notification_IMediator | MultiHandlersAsync | Singleton | ForeachAwait | Large | 1,443.904 ns | 13.7568 ns | 12.8682 ns | 1,444.439 ns | 1.06x slower | 0.01x | 2 | 0.0267 | 448 B | 1.12x more |
| Publish_Notification_Mediator | MultiHandlersAsync | Singleton | ForeachAwait | Large | 1,456.085 ns | 10.6338 ns | 9.9468 ns | 1,455.187 ns | 1.07x slower | 0.01x | 2 | 0.0267 | 448 B | 1.12x more |
| Publish_Notification_IMediator | MultiHandlersAsync | Singleton | TaskWhenAll | Small | 1,109.532 ns | 8.0329 ns | 7.5140 ns | 1,108.076 ns | 1.22x faster | 0.01x | 1 | 0.0229 | 389 B | 1.03x less |
| Publish_Notification_Mediator | MultiHandlersAsync | Singleton | TaskWhenAll | Small | 1,122.842 ns | 11.5114 ns | 10.7678 ns | 1,121.367 ns | 1.20x faster | 0.01x | 1 | 0.0229 | 390 B | 1.03x less |
| Publish_Notification_Baseline | MultiHandlersAsync | Singleton | TaskWhenAll | Small | 1,349.364 ns | 8.4429 ns | 7.8975 ns | 1,348.022 ns | baseline | 2 | 0.0229 | 400 B | ||
| Publish_Notification_MediatR | MultiHandlersAsync | Singleton | TaskWhenAll | Small | 1,457.171 ns | 6.6569 ns | 6.2268 ns | 1,458.352 ns | 1.08x slower | 0.01x | 3 | 0.0610 | 1016 B | 2.54x more |
| Publish_Notification_IMediator | MultiHandlersAsync | Singleton | TaskWhenAll | Large | 1,113.255 ns | 6.6730 ns | 6.2419 ns | 1,112.208 ns | 1.22x faster | 0.01x | 1 | 0.0229 | 387 B | 1.03x less |
| Publish_Notification_Mediator | MultiHandlersAsync | Singleton | TaskWhenAll | Large | 1,123.589 ns | 7.2003 ns | 6.7351 ns | 1,121.830 ns | 1.21x faster | 0.01x | 1 | 0.0229 | 389 B | 1.03x less |
| Publish_Notification_Baseline | MultiHandlersAsync | Singleton | TaskWhenAll | Large | 1,361.744 ns | 3.6281 ns | 3.2162 ns | 1,361.465 ns | baseline | 2 | 0.0229 | 400 B | ||
| Publish_Notification_MediatR | MultiHandlersAsync | Singleton | TaskWhenAll | Large | 1,459.539 ns | 6.9633 ns | 6.5135 ns | 1,459.934 ns | 1.07x slower | 0.01x | 3 | 0.0610 | 1016 B | 2.54x more |
| Publish_Notification_Baseline | MultiHandlersAsync | Transient | ForeachAwait | Small | 1,360.576 ns | 11.3599 ns | 10.6260 ns | 1,361.548 ns | baseline | 1 | 0.0229 | 400 B | ||
| Publish_Notification_MediatR | MultiHandlersAsync | Transient | ForeachAwait | Small | 1,472.921 ns | 6.6100 ns | 6.1830 ns | 1,475.363 ns | 1.08x slower | 0.01x | 2 | 0.0610 | 1016 B | 2.54x more |
| Publish_Notification_Mediator | MultiHandlersAsync | Transient | ForeachAwait | Small | 1,531.177 ns | 14.1508 ns | 13.2367 ns | 1,533.972 ns | 1.13x slower | 0.01x | 3 | 0.0324 | 568 B | 1.42x more |
| Publish_Notification_IMediator | MultiHandlersAsync | Transient | ForeachAwait | Small | 1,535.647 ns | 11.3281 ns | 10.5963 ns | 1,535.608 ns | 1.13x slower | 0.01x | 3 | 0.0324 | 568 B | 1.42x more |
| Publish_Notification_Baseline | MultiHandlersAsync | Transient | ForeachAwait | Large | 1,361.203 ns | 8.0343 ns | 7.5153 ns | 1,359.369 ns | baseline | 1 | 0.0229 | 400 B | ||
| Publish_Notification_MediatR | MultiHandlersAsync | Transient | ForeachAwait | Large | 1,470.910 ns | 5.7379 ns | 5.0865 ns | 1,470.681 ns | 1.08x slower | 0.01x | 2 | 0.0610 | 1016 B | 2.54x more |
| Publish_Notification_Mediator | MultiHandlersAsync | Transient | ForeachAwait | Large | 1,554.203 ns | 11.1376 ns | 10.4181 ns | 1,554.230 ns | 1.14x slower | 0.01x | 3 | 0.0324 | 568 B | 1.42x more |
| Publish_Notification_IMediator | MultiHandlersAsync | Transient | ForeachAwait | Large | 1,561.422 ns | 10.8767 ns | 9.6420 ns | 1,561.401 ns | 1.15x slower | 0.01x | 3 | 0.0324 | 568 B | 1.42x more |
| Publish_Notification_IMediator | MultiHandlersAsync | Transient | TaskWhenAll | Small | 1,160.871 ns | 11.1609 ns | 10.4399 ns | 1,158.965 ns | 1.20x faster | 0.01x | 1 | 0.0305 | 512 B | 1.28x more |
| Publish_Notification_Mediator | MultiHandlersAsync | Transient | TaskWhenAll | Small | 1,168.815 ns | 5.5072 ns | 4.5988 ns | 1,168.810 ns | 1.19x faster | 0.01x | 1 | 0.0305 | 513 B | 1.28x more |
| Publish_Notification_Baseline | MultiHandlersAsync | Transient | TaskWhenAll | Small | 1,393.199 ns | 5.4806 ns | 4.5765 ns | 1,393.044 ns | baseline | 2 | 0.0229 | 400 B | ||
| Publish_Notification_MediatR | MultiHandlersAsync | Transient | TaskWhenAll | Small | 1,482.637 ns | 6.9502 ns | 6.5012 ns | 1,482.997 ns | 1.06x slower | 0.01x | 3 | 0.0610 | 1016 B | 2.54x more |
| Publish_Notification_Mediator | MultiHandlersAsync | Transient | TaskWhenAll | Large | 1,160.911 ns | 8.1053 ns | 7.5817 ns | 1,160.643 ns | 1.19x faster | 0.01x | 1 | 0.0305 | 512 B | 1.28x more |
| Publish_Notification_IMediator | MultiHandlersAsync | Transient | TaskWhenAll | Large | 1,167.397 ns | 7.0012 ns | 6.5489 ns | 1,168.061 ns | 1.18x faster | 0.01x | 1 | 0.0305 | 512 B | 1.28x more |
| Publish_Notification_Baseline | MultiHandlersAsync | Transient | TaskWhenAll | Large | 1,382.508 ns | 11.2717 ns | 9.9921 ns | 1,378.656 ns | baseline | 2 | 0.0229 | 400 B | ||
| Publish_Notification_MediatR | MultiHandlersAsync | Transient | TaskWhenAll | Large | 1,478.223 ns | 7.0994 ns | 6.2935 ns | 1,478.213 ns | 1.07x slower | 0.01x | 3 | 0.0610 | 1016 B | 2.54x more |
An IAsyncEnumerable doing 3 iterations, being fully consumed.
BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.3775)
AMD Ryzen 5 5600X, 1 CPU, 12 logical and 6 physical cores
.NET SDK 8.0.408
[Host] : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Scoped/False : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Scoped/True : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Singleton/False : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Singleton/True : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Transient/False : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
Transient/True : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
| Method | ServiceLifetime | Project type | Mean | Error | StdDev | Median | Ratio | RatioSD | Rank | Gen0 | Allocated | Alloc Ratio |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Stream_Baseline | Scoped | Small | 89.85 ns | 0.865 ns | 0.809 ns | 89.35 ns | baseline | 1 | 0.0052 | 88 B | ||
| Stream_Mediator | Scoped | Small | 146.14 ns | 1.275 ns | 1.192 ns | 145.42 ns | 1.63x slower | 0.02x | 2 | 0.0091 | 152 B | 1.73x more |
| Stream_IMediator | Scoped | Small | 150.43 ns | 0.213 ns | 0.166 ns | 150.41 ns | 1.67x slower | 0.01x | 2 | 0.0091 | 152 B | 1.73x more |
| Stream_MediatR | Scoped | Small | 332.77 ns | 1.076 ns | 0.840 ns | 332.62 ns | 3.70x slower | 0.03x | 3 | 0.0315 | 528 B | 6.00x more |
| Stream_Baseline | Scoped | Large | 87.07 ns | 0.753 ns | 0.705 ns | 86.62 ns | baseline | 1 | 0.0052 | 88 B | ||
| Stream_Mediator | Scoped | Large | 152.77 ns | 1.713 ns | 1.602 ns | 152.03 ns | 1.75x slower | 0.02x | 2 | 0.0091 | 152 B | 1.73x more |
| Stream_IMediator | Scoped | Large | 178.95 ns | 2.468 ns | 2.309 ns | 178.38 ns | 2.06x slower | 0.03x | 3 | 0.0091 | 152 B | 1.73x more |
| Stream_MediatR | Scoped | Large | 330.62 ns | 3.157 ns | 2.953 ns | 328.81 ns | 3.80x slower | 0.04x | 4 | 0.0315 | 528 B | 6.00x more |
| Stream_Baseline | Singleton | Small | 87.71 ns | 0.816 ns | 0.763 ns | 88.12 ns | baseline | 1 | 0.0052 | 88 B | ||
| Stream_Mediator | Singleton | Small | 91.15 ns | 0.962 ns | 0.900 ns | 90.47 ns | 1.04x slower | 0.01x | 2 | 0.0052 | 88 B | 1.00x more |
| Stream_IMediator | Singleton | Small | 92.16 ns | 1.081 ns | 1.011 ns | 92.00 ns | 1.05x slower | 0.01x | 2 | 0.0052 | 88 B | 1.00x more |
| Stream_MediatR | Singleton | Small | 342.91 ns | 3.834 ns | 3.586 ns | 344.55 ns | 3.91x slower | 0.05x | 3 | 0.0315 | 528 B | 6.00x more |
| Stream_Mediator | Singleton | Large | 88.27 ns | 1.241 ns | 1.161 ns | 87.67 ns | 1.01x faster | 0.02x | 1 | 0.0052 | 88 B | 1.00x more |
| Stream_Baseline | Singleton | Large | 88.82 ns | 1.230 ns | 1.151 ns | 88.88 ns | baseline | 1 | 0.0052 | 88 B | ||
| Stream_IMediator | Singleton | Large | 107.42 ns | 0.954 ns | 0.893 ns | 107.87 ns | 1.21x slower | 0.02x | 2 | 0.0052 | 88 B | 1.00x more |
| Stream_MediatR | Singleton | Large | 332.35 ns | 4.381 ns | 4.098 ns | 331.55 ns | 3.74x slower | 0.06x | 3 | 0.0315 | 528 B | 6.00x more |
| Stream_Baseline | Transient | Small | 88.37 ns | 0.884 ns | 0.827 ns | 87.79 ns | baseline | 1 | 0.0052 | 88 B | ||
| Stream_Mediator | Transient | Small | 144.20 ns | 1.549 ns | 1.449 ns | 144.62 ns | 1.63x slower | 0.02x | 2 | 0.0105 | 176 B | 2.00x more |
| Stream_IMediator | Transient | Small | 144.95 ns | 2.670 ns | 2.497 ns | 147.01 ns | 1.64x slower | 0.03x | 2 | 0.0105 | 176 B | 2.00x more |
| Stream_MediatR | Transient | Small | 333.76 ns | 0.590 ns | 0.493 ns | 333.87 ns | 3.78x slower | 0.03x | 3 | 0.0315 | 528 B | 6.00x more |
| Stream_Baseline | Transient | Large | 89.17 ns | 1.076 ns | 1.006 ns | 89.03 ns | baseline | 1 | 0.0052 | 88 B | ||
| Stream_Mediator | Transient | Large | 144.92 ns | 2.628 ns | 2.458 ns | 143.38 ns | 1.63x slower | 0.03x | 2 | 0.0105 | 176 B | 2.00x more |
| Stream_IMediator | Transient | Large | 151.83 ns | 0.145 ns | 0.121 ns | 151.82 ns | 1.70x slower | 0.02x | 3 | 0.0105 | 176 B | 2.00x more |
| Stream_MediatR | Transient | Large | 336.42 ns | 5.135 ns | 4.804 ns | 336.45 ns | 3.77x slower | 0.07x | 4 | 0.0315 | 528 B | 6.00x more |
BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.3775)
AMD Ryzen 5 5600X, 1 CPU, 12 logical and 6 physical cores
.NET SDK 8.0.408
[Host] : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
| Method | ProjectType | ServiceLifetime | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| Cached | Small | Scoped | 3.130 ms | 0.0050 ms | 0.0045 ms | 93.7500 | 31.2500 | - | 1.81 MB |
| Cached | Small | Transient | 3.168 ms | 0.0195 ms | 0.0173 ms | 109.3750 | 15.6250 | - | 1.81 MB |
| Cached | Small | Singleton | 3.187 ms | 0.0102 ms | 0.0085 ms | 93.7500 | 31.2500 | - | 1.81 MB |
| Cold | Small | Transient | 6.233 ms | 0.0311 ms | 0.0291 ms | 210.9375 | 70.3125 | 15.6250 | 3.65 MB |
| Cold | Small | Scoped | 6.249 ms | 0.0646 ms | 0.0604 ms | 210.9375 | 101.5625 | 15.6250 | 3.65 MB |
| Cold | Small | Singleton | 6.334 ms | 0.0841 ms | 0.0787 ms | 210.9375 | 62.5000 | 15.6250 | 3.65 MB |
| Cached | Large | Scoped | 45.282 ms | 0.8975 ms | 0.9603 ms | 500.0000 | - | - | 12 MB |
| Cached | Large | Transient | 45.604 ms | 0.9070 ms | 1.0081 ms | 500.0000 | - | - | 12.03 MB |
| Cached | Large | Singleton | 45.977 ms | 0.9053 ms | 1.1450 ms | 500.0000 | - | - | 12.04 MB |
| Cold | Large | Scoped | 60.706 ms | 1.1644 ms | 1.4726 ms | 1000.0000 | 500.0000 | - | 23.71 MB |
| Cold | Large | Transient | 61.231 ms | 1.1778 ms | 0.9835 ms | 1000.0000 | 500.0000 | - | 23.75 MB |
| Cold | Large | Singleton | 64.621 ms | 1.2744 ms | 2.7158 ms | 1000.0000 | 500.0000 | - | 23.67 MB |