@@ -10,73 +10,97 @@ Foundatio.Mediator aims to get as close to direct method call performance as pos
1010
1111Fire-and-forget dispatch with no return value.
1212
13- | Method | Mean | Allocated |
14- | :-----------------------------------| :-------------:| ----------:|
15- | Direct_Command | 13.76 ns | 0 B |
16- | MediatorNet_Command | 16.78 ns | 0 B |
17- | MediatR_Command | 115.07 ns | 128 B |
18- | Foundatio_Command | 166.59 ns | 200 B |
19- | Wolverine_Command | 514.79 ns | 704 B |
20- | MassTransit_Command | 3,200.25 ns | 4,184 B |
13+ <table style =" width :100% " >
14+ <thead >
15+ <tr ><th style =" text-align :left " >Method</th ><th style =" text-align :right ;white-space :nowrap " >Mean</th ><th style =" text-align :right ;white-space :nowrap " >Allocated</th ></tr >
16+ </thead >
17+ <tbody ><tr ><td style =" width :100% " ><code >Direct_Command</code ></td ><td style =" text-align :right ;white-space :nowrap " >5.536 ns</td ><td style =" text-align :right ;white-space :nowrap " >0 B</td ></tr >
18+ <tr ><td style =" width :100% " ><code >MediatorNet_Command</code ></td ><td style =" text-align :right ;white-space :nowrap " >9.169 ns</td ><td style =" text-align :right ;white-space :nowrap " >0 B</td ></tr >
19+ <tr ><td style =" width :100% " ><code >MediatR_Command</code ></td ><td style =" text-align :right ;white-space :nowrap " >40.458 ns</td ><td style =" text-align :right ;white-space :nowrap " >128 B</td ></tr >
20+ <tr ><td style =" width :100% " ><code >Foundatio_Command</code ></td ><td style =" text-align :right ;white-space :nowrap " >60.987 ns</td ><td style =" text-align :right ;white-space :nowrap " >200 B</td ></tr >
21+ <tr ><td style =" width :100% " ><code >Wolverine_Command</code ></td ><td style =" text-align :right ;white-space :nowrap " >171.784 ns</td ><td style =" text-align :right ;white-space :nowrap " >704 B</td ></tr >
22+ <tr ><td style =" width :100% " ><code >MassTransit_Command</code ></td ><td style =" text-align :right ;white-space :nowrap " >1,213.024 ns</td ><td style =" text-align :right ;white-space :nowrap " >4,184 B</td ></tr >
23+ </tbody >
24+ </table >
2125
2226### Queries
2327
2428Request/response dispatch returning an Order object.
2529
26- | Method | Mean | Allocated |
27- | :-----------------------------------| :-------------:| ----------:|
28- | Direct_Query | 60.42 ns | 192 B |
29- | Direct_QueryWithDependencies | 80.06 ns | 264 B |
30- | MediatorNet_Query | 61.15 ns | 120 B |
31- | MediatR_Query | 146.99 ns | 320 B |
32- | Foundatio_Query | 219.72 ns | 464 B |
33- | Wolverine_Query | 721.84 ns | 1,000 B |
34- | MassTransit_Query | 12,965.13 ns | 12,488 B |
30+ <table style =" width :100% " >
31+ <thead >
32+ <tr ><th style =" text-align :left " >Method</th ><th style =" text-align :right ;white-space :nowrap " >Mean</th ><th style =" text-align :right ;white-space :nowrap " >Allocated</th ></tr >
33+ </thead >
34+ <tbody ><tr ><td style =" width :100% " ><code >Direct_Query</code ></td ><td style =" text-align :right ;white-space :nowrap " >28.961 ns</td ><td style =" text-align :right ;white-space :nowrap " >192 B</td ></tr >
35+ <tr ><td style =" width :100% " ><code >Direct_QueryWithDependencies</code ></td ><td style =" text-align :right ;white-space :nowrap " >33.656 ns</td ><td style =" text-align :right ;white-space :nowrap " >264 B</td ></tr >
36+ <tr ><td style =" width :100% " ><code >MediatorNet_Query</code ></td ><td style =" text-align :right ;white-space :nowrap " >33.510 ns</td ><td style =" text-align :right ;white-space :nowrap " >120 B</td ></tr >
37+ <tr ><td style =" width :100% " ><code >MediatR_Query</code ></td ><td style =" text-align :right ;white-space :nowrap " >60.191 ns</td ><td style =" text-align :right ;white-space :nowrap " >320 B</td ></tr >
38+ <tr ><td style =" width :100% " ><code >Foundatio_Query</code ></td ><td style =" text-align :right ;white-space :nowrap " >93.022 ns</td ><td style =" text-align :right ;white-space :nowrap " >464 B</td ></tr >
39+ <tr ><td style =" width :100% " ><code >Wolverine_Query</code ></td ><td style =" text-align :right ;white-space :nowrap " >257.041 ns</td ><td style =" text-align :right ;white-space :nowrap " >1,000 B</td ></tr >
40+ <tr ><td style =" width :100% " ><code >MassTransit_Query</code ></td ><td style =" text-align :right ;white-space :nowrap " >5,368.266 ns</td ><td style =" text-align :right ;white-space :nowrap " >12,488 B</td ></tr >
41+ </tbody >
42+ </table >
3543
3644### Events (Publish)
3745
3846Notification dispatched to 2 handlers.
3947
40- | Method | Mean | Allocated |
41- | :-----------------------------------| :-------------:| ----------:|
42- | Direct_Event | 13.71 ns | 0 B |
43- | MediatorNet_Publish | 19.56 ns | 0 B |
44- | MediatR_Publish | 266.13 ns | 792 B |
45- | Foundatio_Publish | 322.47 ns | 336 B |
46- | Wolverine_Publish | 2,138.78 ns | 1,688 B |
47- | MassTransit_Publish | 5,249.18 ns | 6,008 B |
48+ <table style =" width :100% " >
49+ <thead >
50+ <tr ><th style =" text-align :left " >Method</th ><th style =" text-align :right ;white-space :nowrap " >Mean</th ><th style =" text-align :right ;white-space :nowrap " >Allocated</th ></tr >
51+ </thead >
52+ <tbody ><tr ><td style =" width :100% " ><code >Direct_Event</code ></td ><td style =" text-align :right ;white-space :nowrap " >5.689 ns</td ><td style =" text-align :right ;white-space :nowrap " >0 B</td ></tr >
53+ <tr ><td style =" width :100% " ><code >MediatorNet_Publish</code ></td ><td style =" text-align :right ;white-space :nowrap " >10.769 ns</td ><td style =" text-align :right ;white-space :nowrap " >0 B</td ></tr >
54+ <tr ><td style =" width :100% " ><code >MediatR_Publish</code ></td ><td style =" text-align :right ;white-space :nowrap " >101.197 ns</td ><td style =" text-align :right ;white-space :nowrap " >792 B</td ></tr >
55+ <tr ><td style =" width :100% " ><code >Foundatio_Publish</code ></td ><td style =" text-align :right ;white-space :nowrap " >110.246 ns</td ><td style =" text-align :right ;white-space :nowrap " >336 B</td ></tr >
56+ <tr ><td style =" width :100% " ><code >Wolverine_Publish</code ></td ><td style =" text-align :right ;white-space :nowrap " >1,829.026 ns</td ><td style =" text-align :right ;white-space :nowrap " >2,840 B</td ></tr >
57+ <tr ><td style =" width :100% " ><code >MassTransit_Publish</code ></td ><td style =" text-align :right ;white-space :nowrap " >2,047.094 ns</td ><td style =" text-align :right ;white-space :nowrap " >6,008 B</td ></tr >
58+ </tbody >
59+ </table >
4860
4961### Full Query (Dependencies + Middleware)
5062
5163Query where handler has an injected service (IOrderService) and timing middleware (Before/Finally or IPipelineBehavior).
5264
53- | Method | Mean | Allocated |
54- | :-----------------------------------| :-------------:| ----------:|
55- | MediatorNet_FullQuery | 90.24 ns | 192 B |
56- | MediatR_FullQuery | 356.76 ns | 744 B |
57- | Foundatio_FullQuery | 484.14 ns | 776 B |
58- | Wolverine_FullQuery | 714.50 ns | 1,000 B |
59- | MassTransit_FullQuery | 13,004.54 ns | 12,560 B |
65+ <table style =" width :100% " >
66+ <thead >
67+ <tr ><th style =" text-align :left " >Method</th ><th style =" text-align :right ;white-space :nowrap " >Mean</th ><th style =" text-align :right ;white-space :nowrap " >Allocated</th ></tr >
68+ </thead >
69+ <tbody ><tr ><td style =" width :100% " ><code >MediatorNet_FullQuery</code ></td ><td style =" text-align :right ;white-space :nowrap " >41.487 ns</td ><td style =" text-align :right ;white-space :nowrap " >192 B</td ></tr >
70+ <tr ><td style =" width :100% " ><code >MediatR_FullQuery</code ></td ><td style =" text-align :right ;white-space :nowrap " >139.304 ns</td ><td style =" text-align :right ;white-space :nowrap " >744 B</td ></tr >
71+ <tr ><td style =" width :100% " ><code >Foundatio_FullQuery</code ></td ><td style =" text-align :right ;white-space :nowrap " >192.957 ns</td ><td style =" text-align :right ;white-space :nowrap " >776 B</td ></tr >
72+ <tr ><td style =" width :100% " ><code >Wolverine_FullQuery</code ></td ><td style =" text-align :right ;white-space :nowrap " >262.386 ns</td ><td style =" text-align :right ;white-space :nowrap " >1,000 B</td ></tr >
73+ <tr ><td style =" width :100% " ><code >MassTransit_FullQuery</code ></td ><td style =" text-align :right ;white-space :nowrap " >5,578.827 ns</td ><td style =" text-align :right ;white-space :nowrap " >12,560 B</td ></tr >
74+ </tbody >
75+ </table >
6076
6177### Cascading Messages
6278
6379CreateOrder returns an Order and publishes OrderCreatedEvent to 2 handlers. Foundatio uses tuple returns for automatic cascading; other libraries publish manually.
6480
65- | Method | Mean | Allocated |
66- | :-----------------------------------| :-------------:| ----------:|
67- | MediatorNet_CascadingMessages | 88.55 ns | 144 B |
68- | MediatR_CascadingMessages | 516.09 ns | 1,168 B |
69- | Foundatio_CascadingMessages | 297.90 ns | 568 B |
70- | Wolverine_CascadingMessages | 3,494.41 ns | 2,912 B |
71- | MassTransit_CascadingMessages | 40,247.18 ns | 18,808 B |
81+ <table style =" width :100% " >
82+ <thead >
83+ <tr ><th style =" text-align :left " >Method</th ><th style =" text-align :right ;white-space :nowrap " >Mean</th ><th style =" text-align :right ;white-space :nowrap " >Allocated</th ></tr >
84+ </thead >
85+ <tbody ><tr ><td style =" width :100% " ><code >MediatorNet_CascadingMessages</code ></td ><td style =" text-align :right ;white-space :nowrap " >45.668 ns</td ><td style =" text-align :right ;white-space :nowrap " >144 B</td ></tr >
86+ <tr ><td style =" width :100% " ><code >MediatR_CascadingMessages</code ></td ><td style =" text-align :right ;white-space :nowrap " >173.084 ns</td ><td style =" text-align :right ;white-space :nowrap " >1,168 B</td ></tr >
87+ <tr ><td style =" width :100% " ><code >Foundatio_CascadingMessages</code ></td ><td style =" text-align :right ;white-space :nowrap " >116.241 ns</td ><td style =" text-align :right ;white-space :nowrap " >568 B</td ></tr >
88+ <tr ><td style =" width :100% " ><code >Wolverine_CascadingMessages</code ></td ><td style =" text-align :right ;white-space :nowrap " >2,355.686 ns</td ><td style =" text-align :right ;white-space :nowrap " >4,064 B</td ></tr >
89+ <tr ><td style =" width :100% " ><code >MassTransit_CascadingMessages</code ></td ><td style =" text-align :right ;white-space :nowrap " >8,922.815 ns</td ><td style =" text-align :right ;white-space :nowrap " >18,746 B</td ></tr >
90+ </tbody >
91+ </table >
7292
7393### Short-Circuit Middleware (Foundatio Only)
7494
7595Middleware returns cached result; handler is never invoked. Useful for caching or authorization.
7696
77- | Method | Mean | Allocated |
78- | :-----------------------------------| :-------------:| ----------:|
79- | Foundatio_ShortCircuit | 164.74 ns | 368 B |
97+ <table style =" width :100% " >
98+ <thead >
99+ <tr ><th style =" text-align :left " >Method</th ><th style =" text-align :right ;white-space :nowrap " >Mean</th ><th style =" text-align :right ;white-space :nowrap " >Allocated</th ></tr >
100+ </thead >
101+ <tbody ><tr ><td style =" width :100% " ><code >Foundatio_ShortCircuit</code ></td ><td style =" text-align :right ;white-space :nowrap " >65.948 ns</td ><td style =" text-align :right ;white-space :nowrap " >368 B</td ></tr >
102+ </tbody >
103+ </table >
80104
81105## Running Benchmarks Locally
82106
0 commit comments