Skip to content
Myr

BENCHMARKS.md

This file

Path

BENCHMARKS.md

291 lines · 11.8 KiB · Markdown

Last changed by

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

History of this file

Take it

The walk stopped after 200 commits: lines older than cf32d2d point at it.

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

lines 1–7why, one step back
1# Gin Benchmark Report
23**Machine:** Apple M4 Pro4**OS:** macOS (Darwin 25.3.0), arm645**Date:** March 15th, 20266**Gin Version:** v1.12.07**Go Version:** 1.25.8 darwin/arm64

chore(deps): bump github.com/pelletier/go-toml/v2 from 2.2.2 to 2.2.4 (#4212)dependabot[bot]before adoptioncf32d2d

line 8why, one step back
8**Source:** [Go HTTP Router Benchmark](https://github.com/gin-gonic/go-http-routing-benchmark)

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

lines 9–13why, one step back
9
10---1112## Table of Contents13

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

line 14why, one step back
14- [Summary](#summary)

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 15why, one step back
15- [Memory Consumption](#memory-consumption)

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

lines 16–20why, one step back
16- [Benchmark Results](#benchmark-results)
17 - [GitHub API (203 routes)](#github-api-203-routes)18 - [Google+ API (13 routes)](#google-api-13-routes)19 - [Parse API (26 routes)](#parse-api-26-routes)20 - [Static Routes (157 routes)](#static-routes-157-routes)

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 21why, one step back
21- [Micro Benchmarks](#micro-benchmarks)

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

lines 22–25why, one step back
22 - [Single Param](#single-param)
23 - [5 Params](#5-params)24 - [20 Params](#20-params)25 - [Param Write](#param-write)

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

lines 26–28why, one step back
26
27---28

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

lines 29–58why, one step back
29## Summary
3031The table below ranks all routers by **GitHub API throughput** (203 routes, all methods), which best represents real-world routing workloads. _Lower ns/op is better._3233| Rank | Router | ns/op | B/op | allocs/op | Zero-alloc |34| :--: | :------------ | --------: | --------: | --------: | :----------------: |35| 1 | **Gin** | 9,944 | 0 | 0 | :white_check_mark: |36| 2 | **BunRouter** | 10,281 | 0 | 0 | :white_check_mark: |37| 3 | **Echo** | 11,072 | 0 | 0 | :white_check_mark: |38| 4 | HttpRouter | 15,059 | 13,792 | 167 | |39| 5 | HttpTreeMux | 49,302 | 65,856 | 671 | |40| 6 | Chi | 94,376 | 130,817 | 740 | |41| 7 | Beego | 101,941 | 71,456 | 609 | |42| 8 | Fiber | 109,148 | 0 | 0 | :white_check_mark: |43| 9 | Macaron | 121,785 | 147,784 | 1,624 | |44| 10 | Goji v2 | 242,849 | 313,744 | 3,712 | |45| 11 | GoRestful | 885,678 | 1,006,744 | 3,009 | |46| 12 | GorillaMux | 1,316,844 | 225,667 | 1,588 | |4748**Key takeaways:**4950- **Gin**, **BunRouter**, and **Echo** form the top tier — all achieve zero heap allocations and route the full GitHub API in ~10 us.51- **HttpRouter** remains extremely fast but incurs 1 alloc per parameterized route (167 allocs for 203 routes).52- **Fiber** also achieves zero allocations, but its fasthttp-based benchmark infrastructure adds per-iteration reset overhead — do not compare its absolute ns/op directly with net/http routers.53- **GorillaMux** and **GoRestful** are feature-rich but orders of magnitude slower, making them less suitable for latency-sensitive applications.5455> **Fiber caveat:** Fiber benchmarks use `fasthttp.RequestCtx` with per-iteration Reset, which adds constant overhead not present in net/http benchmarks. Fiber-vs-Fiber comparisons are valid; cross-framework comparisons should be interpreted with care.5657---58

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

lines 59–60why, one step back
59## Memory Consumption
60

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

line 61why, one step back
61Memory required for loading the routing structure (lower is better). Sorted by bytes ascending.

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

lines 62–64why, one step back
62
63### Static Routes: 15764

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

lines 65–66why, one step back
65| Router | Bytes |
66| :------------- | ---------: |

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 67why, one step back
67| **HttpRouter** | **21,680** |

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

lines 68–79why, one step back
68| **Gin** | **34,408** |
69| **Macaron** | **36,976** |70| BunRouter | 51,232 |71| Fiber | 59,248 |72| HttpServeMux | 71,728 |73| HttpTreeMux | 73,448 |74| Chi | 83,160 |75| Echo | 91,976 |76| Beego | 98,824 |77| Goji v2 | 117,952 |78| GorillaMux | 599,496 |79| GoRestful | 819,704 |

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

lines 80–82why, one step back
80
81### GitHub API Routes: 20382

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

lines 83–96why, one step back
83| Router | Bytes |
84| :-------------- | ---------: |85| **HttpRouter** | **37,072** |86| **Gin** | **58,840** |87| **HttpTreeMux** | **78,800** |88| Macaron | 90,632 |89| BunRouter | 93,776 |90| Chi | 94,888 |91| Echo | 117,784 |92| Goji v2 | 118,640 |93| Beego | 150,840 |94| Fiber | 163,832 |95| GoRestful | 1,270,848 |96| GorillaMux | 1,319,696 |

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

lines 97–99why, one step back
97
98### Google+ API Routes: 1399

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

lines 100–101why, one step back
100| Router | Bytes |
101| :------------- | --------: |

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 102why, one step back
102| **HttpRouter** | **2,776** |

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

lines 103–113why, one step back
103| **Gin** | **4,576** |
104| **BunRouter** | **7,360** |105| HttpTreeMux | 7,440 |106| Chi | 8,008 |107| Goji v2 | 8,096 |108| Macaron | 8,672 |109| Beego | 10,256 |110| Fiber | 10,840 |111| Echo | 10,968 |112| GorillaMux | 68,000 |113| GoRestful | 72,536 |

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

lines 114–116why, one step back
114
115### Parse API Routes: 26116

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

lines 117–130why, one step back
117| Router | Bytes |
118| :-------------- | --------: |119| **HttpRouter** | **5,024** |120| **Gin** | **7,896** |121| **HttpTreeMux** | **7,848** |122| BunRouter | 9,336 |123| Chi | 9,656 |124| Echo | 13,816 |125| Macaron | 13,704 |126| Fiber | 15,352 |127| Goji v2 | 16,064 |128| Beego | 19,256 |129| GorillaMux | 105,384 |130| GoRestful | 121,200 |

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

lines 131–133why, one step back
131
132---133

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

line 134why, one step back
134## Benchmark Results

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 135why, one step back
135

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

line 136why, one step back
136### GitHub API (203 routes)

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

lines 137–139why, one step back
137
138Routing all 203 GitHub API endpoints per operation.139

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

lines 140–153why, one step back
140| Rank | Router | ns/op | B/op | allocs/op |
141| :--: | :------------ | --------: | --------: | --------: |142| 1 | **Gin** | 9,944 | 0 | 0 |143| 2 | **BunRouter** | 10,281 | 0 | 0 |144| 3 | **Echo** | 11,072 | 0 | 0 |145| 4 | HttpRouter | 15,059 | 13,792 | 167 |146| 5 | HttpTreeMux | 49,302 | 65,856 | 671 |147| 6 | Chi | 94,376 | 130,817 | 740 |148| 7 | Beego | 101,941 | 71,456 | 609 |149| 8 | Fiber | 109,148 | 0 | 0 |150| 9 | Macaron | 121,785 | 147,784 | 1,624 |151| 10 | Goji v2 | 242,849 | 313,744 | 3,712 |152| 11 | GoRestful | 885,678 | 1,006,744 | 3,009 |153| 12 | GorillaMux | 1,316,844 | 225,667 | 1,588 |

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 154why, one step back
154

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

line 155why, one step back
155### Google+ API (13 routes)

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

lines 156–158why, one step back
156
157Routing all 13 Google+ API endpoints per operation.158

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

lines 159–172why, one step back
159| Rank | Router | ns/op | B/op | allocs/op |
160| :--: | :------------ | -----: | -----: | --------: |161| 1 | **BunRouter** | 348.5 | 0 | 0 |162| 2 | **Gin** | 429.7 | 0 | 0 |163| 3 | **Echo** | 451.1 | 0 | 0 |164| 4 | HttpRouter | 668.6 | 640 | 11 |165| 5 | HttpTreeMux | 2,428 | 4,032 | 38 |166| 6 | Fiber | 2,506 | 0 | 0 |167| 7 | Chi | 5,333 | 8,480 | 48 |168| 8 | Beego | 5,927 | 4,576 | 39 |169| 9 | Macaron | 7,294 | 9,464 | 104 |170| 10 | Goji v2 | 8,000 | 15,120 | 115 |171| 11 | GorillaMux | 14,707 | 14,448 | 102 |172| 12 | GoRestful | 24,189 | 60,720 | 193 |

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 173why, one step back
173

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

line 174why, one step back
174### Parse API (26 routes)

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

lines 175–177why, one step back
175
176Routing all 26 Parse API endpoints per operation.177

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

lines 178–191why, one step back
178| Rank | Router | ns/op | B/op | allocs/op |
179| :--: | :------------ | -----: | ------: | --------: |180| 1 | **BunRouter** | 588.2 | 0 | 0 |181| 2 | **Gin** | 712.1 | 0 | 0 |182| 3 | **Echo** | 742.1 | 0 | 0 |183| 4 | HttpRouter | 948.5 | 640 | 16 |184| 5 | HttpTreeMux | 3,372 | 5,728 | 51 |185| 6 | Fiber | 4,250 | 0 | 0 |186| 7 | Chi | 8,863 | 14,944 | 84 |187| 8 | Beego | 10,541 | 9,152 | 78 |188| 9 | Macaron | 13,635 | 18,928 | 208 |189| 10 | Goji v2 | 13,264 | 29,456 | 199 |190| 11 | GorillaMux | 25,886 | 26,960 | 198 |191| 12 | GoRestful | 54,780 | 131,728 | 380 |

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 192why, one step back
192

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

line 193why, one step back
193### Static Routes (157 routes)

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 194why, one step back
194

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

line 195why, one step back
195Routing all 157 static routes per operation. Includes http.ServeMux as baseline.

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 196why, one step back
196

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

lines 197–211why, one step back
197| Rank | Router | ns/op | B/op | allocs/op |
198| :--: | :-------------- | ------: | ------: | --------: |199| 1 | **HttpRouter** | 4,177 | 0 | 0 |200| 2 | **HttpTreeMux** | 5,363 | 0 | 0 |201| 3 | **Gin** | 5,528 | 0 | 0 |202| 4 | BunRouter | 5,997 | 0 | 0 |203| 5 | Echo | 6,897 | 0 | 0 |204| — | HttpServeMux | 18,172 | 0 | 0 |205| 6 | Fiber | 29,310 | 0 | 0 |206| 7 | Chi | 41,317 | 57,776 | 314 |207| 8 | Beego | 68,255 | 55,264 | 471 |208| 9 | Macaron | 81,824 | 114,296 | 1,256 |209| 10 | Goji v2 | 84,459 | 175,840 | 1,099 |210| 11 | GorillaMux | 302,825 | 133,137 | 1,099 |211| 12 | GoRestful | 436,510 | 677,824 | 2,193 |

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

lines 212–214why, one step back
212
213---214

chore(deps): bump github.com/pelletier/go-toml/v2 from 2.2.2 to 2.2.4 (#4212)dependabot[bot]before adoptioncf32d2d

line 215why, one step back
215## Micro Benchmarks

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 216why, one step back
216

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

line 217why, one step back
217### Single Param

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 218why, one step back
218

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

line 219why, one step back
219Route: `/user/:name` — Request: `GET /user/gordon`

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 220why, one step back
220

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

lines 221–234why, one step back
221| Rank | Router | ns/op | B/op | allocs/op |
222| :--: | :------------ | ----: | ----: | --------: |223| 1 | **BunRouter** | 12.22 | 0 | 0 |224| 2 | **Echo** | 17.75 | 0 | 0 |225| 3 | **Gin** | 23.31 | 0 | 0 |226| 4 | HttpRouter | 31.88 | 32 | 1 |227| 5 | Fiber | 114.4 | 0 | 0 |228| 6 | HttpTreeMux | 165.0 | 352 | 3 |229| 7 | Chi | 332.2 | 704 | 4 |230| 8 | Beego | 348.8 | 352 | 3 |231| 9 | Goji v2 | 494.3 | 1,136 | 8 |232| 10 | GorillaMux | 630.6 | 1,152 | 8 |233| 11 | Macaron | 708.0 | 1,064 | 10 |234| 12 | GoRestful | 1,394 | 4,600 | 15 |

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 235why, one step back
235

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

line 236why, one step back
236### 5 Params

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 237why, one step back
237

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

line 238why, one step back
238Route: `/:a/:b/:c/:d/:e` — Request: `GET /test/test/test/test/test`

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 239why, one step back
239

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

lines 240–253why, one step back
240| Rank | Router | ns/op | B/op | allocs/op |
241| :--: | :------------ | ----: | ----: | --------: |242| 1 | **BunRouter** | 41.86 | 0 | 0 |243| 2 | **Echo** | 43.76 | 0 | 0 |244| 3 | **Gin** | 44.20 | 0 | 0 |245| 4 | HttpRouter | 83.74 | 160 | 1 |246| 5 | Fiber | 271.6 | 0 | 0 |247| 6 | HttpTreeMux | 358.8 | 576 | 6 |248| 7 | Chi | 453.7 | 704 | 4 |249| 8 | Beego | 480.3 | 352 | 3 |250| 9 | Goji v2 | 532.4 | 1,200 | 8 |251| 10 | Macaron | 799.7 | 1,064 | 10 |252| 11 | GorillaMux | 972.6 | 1,216 | 8 |253| 12 | GoRestful | 1,579 | 4,712 | 15 |

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 254why, one step back
254

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

line 255why, one step back
255### 20 Params

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 256why, one step back
256

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

line 257why, one step back
257Route: `/:a/:b/.../:t` (20 segments) — Request: `GET /a/b/.../t`

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 258why, one step back
258

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

lines 259–272why, one step back
259| Rank | Router | ns/op | B/op | allocs/op |
260| :--: | :------------ | ----: | ----: | --------: |261| 1 | **Gin** | 121.7 | 0 | 0 |262| 2 | **Echo** | 127.5 | 0 | 0 |263| 3 | **BunRouter** | 211.4 | 0 | 0 |264| 4 | HttpRouter | 290.2 | 704 | 1 |265| 5 | Fiber | 466.1 | 0 | 0 |266| 6 | Goji v2 | 745.3 | 1,440 | 8 |267| 7 | Beego | 1,099 | 352 | 3 |268| 8 | Chi | 1,805 | 2,504 | 9 |269| 9 | HttpTreeMux | 1,857 | 3,144 | 13 |270| 10 | Macaron | 2,058 | 2,864 | 15 |271| 11 | GorillaMux | 2,223 | 3,272 | 13 |272| 12 | GoRestful | 3,337 | 7,008 | 20 |

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 273why, one step back
273

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

line 274why, one step back
274### Param Write

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 275why, one step back
275

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

line 276why, one step back
276Route: `/user/:name` with response write — Request: `GET /user/gordon`

docs(benchmarks): update benchmark report with Gin v1.12.0 results (#4581)Bo-Yi Wubefore adoption65d1c47

line 277why, one step back
277

docs(readme): update benchmark results with latest data (#4583)Bo-Yi Wubefore adoptionecd26c8

lines 278–291why, one step back
278| Rank | Router | ns/op | B/op | allocs/op |
279| :--: | :------------ | ----: | ----: | --------: |280| 1 | **BunRouter** | 25.86 | 0 | 0 |281| 2 | **Gin** | 27.65 | 0 | 0 |282| 3 | HttpRouter | 37.40 | 32 | 1 |283| 4 | Echo | 47.94 | 8 | 1 |284| 5 | Fiber | 125.7 | 0 | 0 |285| 6 | HttpTreeMux | 180.4 | 352 | 3 |286| 7 | Chi | 348.3 | 704 | 4 |287| 8 | Beego | 386.1 | 360 | 4 |288| 9 | Goji v2 | 516.9 | 1,168 | 10 |289| 10 | GorillaMux | 665.5 | 1,152 | 8 |290| 11 | Macaron | 784.3 | 1,112 | 13 |291| 12 | GoRestful | 1,534 | 4,608 | 16 |