Skip to content

Commit a2fc6cb

Browse files
committed
Better benchmark formatting
1 parent cde4a3b commit a2fc6cb

File tree

2 files changed

+98
-6
lines changed

2 files changed

+98
-6
lines changed

.github/scripts/Update-BenchmarkDocs.ps1

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,41 @@ Write-Host "Parsing benchmark results..." -ForegroundColor Cyan
5959
$csv = Import-Csv $ResultsFile
6060
$currentDate = Get-Date -Format 'yyyy-MM-dd'
6161

62+
# Group benchmarks by operation type (Command, Query, Event/Publish, QueryWithDependencies)
63+
$groups = @{
64+
'Command' = @()
65+
'Query' = @()
66+
'Publish' = @()
67+
'QueryWithDependencies' = @()
68+
}
69+
70+
# Define the order of implementations
71+
$implOrder = @('Direct', 'Foundatio', 'MediatR', 'MassTransit')
72+
73+
foreach ($row in $csv) {
74+
$method = $row.Method
75+
if ($method -match 'QueryWithDependencies') {
76+
$groups['QueryWithDependencies'] += $row
77+
} elseif ($method -match 'Command') {
78+
$groups['Command'] += $row
79+
} elseif ($method -match 'Query') {
80+
$groups['Query'] += $row
81+
} elseif ($method -match 'Publish|Event') {
82+
$groups['Publish'] += $row
83+
}
84+
}
85+
86+
# Sort each group by implementation order
87+
foreach ($key in $groups.Keys) {
88+
$groups[$key] = $groups[$key] | Sort-Object {
89+
$method = $_.Method
90+
for ($i = 0; $i -lt $implOrder.Count; $i++) {
91+
if ($method -match "^$($implOrder[$i])_") { return $i }
92+
}
93+
return 999
94+
}
95+
}
96+
6297
# Build the markdown content
6398
$markdown = @"
6499
# Performance
@@ -68,13 +103,53 @@ Foundatio Mediator achieves near-direct call performance through C# interceptors
68103
## Benchmark Results
69104
70105
> 📊 **Last Updated:** $currentDate
71-
> 🔧 **Generated automatically by [GitHub Actions](https://github.com/FoundatioFx/Foundatio.Mediator/actions/workflows/benchmarks.yml)**
106+
107+
### Commands
72108
73109
| Method | Mean | Allocated |
74110
|:-------|-----:|----------:|
75111
"@
76112

77-
foreach ($row in $csv) {
113+
foreach ($row in $groups['Command']) {
114+
$markdown += "`n| $($row.Method) | $($row.Mean) | $($row.Allocated) |"
115+
}
116+
117+
$markdown += @"
118+
119+
120+
### Queries
121+
122+
| Method | Mean | Allocated |
123+
|:-------|-----:|----------:|
124+
"@
125+
126+
foreach ($row in $groups['Query']) {
127+
$markdown += "`n| $($row.Method) | $($row.Mean) | $($row.Allocated) |"
128+
}
129+
130+
$markdown += @"
131+
132+
133+
### Events (Publish)
134+
135+
| Method | Mean | Allocated |
136+
|:-------|-----:|----------:|
137+
"@
138+
139+
foreach ($row in $groups['Publish']) {
140+
$markdown += "`n| $($row.Method) | $($row.Mean) | $($row.Allocated) |"
141+
}
142+
143+
$markdown += @"
144+
145+
146+
### Queries with Dependencies
147+
148+
| Method | Mean | Allocated |
149+
|:-------|-----:|----------:|
150+
"@
151+
152+
foreach ($row in $groups['QueryWithDependencies']) {
78153
$markdown += "`n| $($row.Method) | $($row.Mean) | $($row.Allocated) |"
79154
}
80155

docs/guide/performance.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,38 @@ Foundatio Mediator achieves near-direct call performance through C# interceptors
77
> 📊 **Last Updated:** 2025-12-22
88
> 🔧 **Generated automatically by [GitHub Actions](https://github.com/FoundatioFx/Foundatio.Mediator/actions/workflows/benchmarks.yml)**
99
10+
### Commands
11+
1012
| Method | Mean | Allocated |
1113
|:-------|-----:|----------:|
1214
| Direct_Command | 7.143 ns | 0 B |
13-
| Direct_Query | 30.135 ns | 192 B |
14-
| Direct_Event | 5.898 ns | 0 B |
15-
| Direct_QueryWithDependencies | 34.721 ns | 264 B |
1615
| Foundatio_Command | 64.364 ns | 200 B |
1716
| MediatR_Command | 38.909 ns | 128 B |
1817
| MassTransit_Command | 1,249.631 ns | 4168 B |
18+
19+
### Queries
20+
21+
| Method | Mean | Allocated |
22+
|:-------|-----:|----------:|
23+
| Direct_Query | 30.135 ns | 192 B |
1924
| Foundatio_Query | 95.543 ns | 464 B |
2025
| MediatR_Query | 63.362 ns | 320 B |
2126
| MassTransit_Query | 5,583.887 ns | 12472 B |
27+
28+
### Events (Publish)
29+
30+
| Method | Mean | Allocated |
31+
|:-------|-----:|----------:|
32+
| Direct_Event | 5.898 ns | 0 B |
2233
| Foundatio_Publish | 144.341 ns | 648 B |
2334
| MediatR_Publish | 49.039 ns | 288 B |
2435
| MassTransit_Publish | 1,394.933 ns | 4320 B |
36+
37+
### Queries with Dependencies
38+
39+
| Method | Mean | Allocated |
40+
|:-------|-----:|----------:|
41+
| Direct_QueryWithDependencies | 34.721 ns | 264 B |
2542
| Foundatio_QueryWithDependencies | 105.046 ns | 536 B |
2643
| MediatR_QueryWithDependencies | 67.966 ns | 392 B |
2744
| MassTransit_QueryWithDependencies | 5,642.623 ns | 12544 B |
@@ -31,4 +48,4 @@ Foundatio Mediator achieves near-direct call performance through C# interceptors
3148
```bash
3249
cd benchmarks/Foundatio.Mediator.Benchmarks
3350
dotnet run -c Release
34-
```
51+
```

0 commit comments

Comments
 (0)