mirror of
https://github.com/lukaszraczylo/go-telegram.git
synced 2026-06-05 22:43:59 +00:00
test(bench): cross-library benchmarks vs top 5 go telegram libraries
Adds test/benchmarks/ as a separate Go module so competitor deps
(go-telegram-bot-api/v5, telebot.v3, go-telegram/bot, telego,
echotron/v3) stay out of the root go.mod.
Hot paths covered:
- Webhook decode (small Update -> typed Update struct)
- Large unmarshal (Update with entities + reply markup + photo array)
- API round-trip (sendMessage against httptest.Server)
- Dispatch route (20 handlers, last-registered matches)
Results on Apple M4 Max / go1.26.2: ours wins 3 of 4 paths and is
2nd of 5 in the round-trip path. Full report at
docs/benchmarks/2026-05-10-comparison.md, raw output committed under
test/benchmarks/results/.
Caveats called out in the report:
- codec asymmetry (we ship goccy/go-json; competitors mostly stdlib)
- echotron call bench skipped — built-in rate limiter not externally
configurable; would measure throttling, not the library
- dispatch bench limited to libs with a public sync entry point
(ours, telebot, gobot); gotba has no dispatcher, telego/echotron
use channel/per-chat paradigms not directly comparable
Also gitignores docs/superpowers/ (local brainstorm/spec scratch)
and regenerates docs/reference/dispatch.md after the new
Router.Process method.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
# Cross-library benchmarks
|
||||
|
||||
Apples-to-apples micro-benchmarks comparing `lukaszraczylo/go-telegram` against the five most-starred Go Telegram libraries:
|
||||
|
||||
- `github.com/go-telegram-bot-api/telegram-bot-api/v5`
|
||||
- `gopkg.in/telebot.v3` (tucnak)
|
||||
- `github.com/go-telegram/bot`
|
||||
- `github.com/mymmrac/telego`
|
||||
- `github.com/NicoNex/echotron/v3`
|
||||
|
||||
Lives in its own Go module so competitor dependencies don't leak into the main repo's `go.mod`.
|
||||
|
||||
## Run
|
||||
|
||||
```bash
|
||||
go test -count=10 -bench=. -benchmem | tee results/raw.txt
|
||||
go install golang.org/x/perf/cmd/benchstat@latest # one-time
|
||||
benchstat results/raw.txt > results/benchstat.txt
|
||||
```
|
||||
|
||||
## Hot paths covered
|
||||
|
||||
| File | Path |
|
||||
|------|------|
|
||||
| `webhook_bench_test.go` | Decode small text-message Update from JSON |
|
||||
| `unmarshal_bench_test.go` | Decode large Update (entities + reply markup + photo array) |
|
||||
| `call_bench_test.go` | `sendMessage` round-trip against `httptest.Server` |
|
||||
| `dispatch_bench_test.go` | Route an Update through 20 registered handlers (worst-case match) |
|
||||
|
||||
## Fixtures
|
||||
|
||||
`shared/fixtures.go` defines the JSON payloads and the mock HTTP server. Every library decodes the same bytes; every round-trip hits the same canned response.
|
||||
|
||||
## Latest results
|
||||
|
||||
See [`../../docs/benchmarks/2026-05-10-comparison.md`](../../docs/benchmarks/2026-05-10-comparison.md) for the rendered comparison.
|
||||
Reference in New Issue
Block a user