mirror of
https://github.com/lukaszraczylo/go-telegram.git
synced 2026-06-05 22:43:59 +00:00
75c7ce3119
Two changes that together cut allocs/call from 15 to 13 (client-internal bench) and per-call CPU from 600ns to 455ns (-24%) on the no-HTTP path: 1. Codec gets an optional BodyEncoder extension (MarshalTo io.Writer). When present, encodeJSONBody stream-encodes the request directly into a pooled *bytes.Buffer instead of allocating a [2-step] Marshal+Reader pair. DefaultCodec implements it via goccy/go-json.NewEncoder. 2. *Bot caches the parsed base URL on construction. buildRequest skips net/http.NewRequestWithContext for the common case and constructs *http.Request manually — clones the URL by value, sets the method path, and populates ContentLength + GetBody from the body's concrete type so RetryDoer's body-replay across attempts still works. Cross-library bench (sendMessage round-trip vs httptest.Server): -2 allocs/call (104 -> 102), bytes -1.2%, time within noise (real HTTP plumbing dominates). The CPU win is visible on synthetic stub-doer benches and translates to lower GC pressure on sustained-throughput workloads. Slow-path fallback preserved for codecs that don't implement BodyEncoder and for *Bot instances where url.Parse on the configured base failed — they take the original NewRequestWithContext path.
207 lines
20 KiB
Plaintext
207 lines
20 KiB
Plaintext
goos: darwin
|
|
goarch: arm64
|
|
pkg: github.com/lukaszraczylo/go-telegram/test/benchmarks
|
|
cpu: Apple M4 Max
|
|
BenchmarkCall_ours-16 27756 39971 ns/op 11497 B/op 103 allocs/op
|
|
BenchmarkCall_ours-16 30495 39111 ns/op 11329 B/op 102 allocs/op
|
|
BenchmarkCall_ours-16 29250 41427 ns/op 11356 B/op 102 allocs/op
|
|
BenchmarkCall_ours-16 29766 39680 ns/op 11366 B/op 102 allocs/op
|
|
BenchmarkCall_ours-16 29157 40066 ns/op 11338 B/op 102 allocs/op
|
|
BenchmarkCall_ours-16 30567 38404 ns/op 11276 B/op 102 allocs/op
|
|
BenchmarkCall_ours-16 30470 38923 ns/op 11306 B/op 102 allocs/op
|
|
BenchmarkCall_ours-16 30520 40212 ns/op 11364 B/op 102 allocs/op
|
|
BenchmarkCall_ours-16 30315 39595 ns/op 11361 B/op 102 allocs/op
|
|
BenchmarkCall_ours-16 28747 41549 ns/op 11434 B/op 102 allocs/op
|
|
BenchmarkCall_gotba-16 28140 43735 ns/op 11255 B/op 125 allocs/op
|
|
BenchmarkCall_gotba-16 27189 43528 ns/op 11247 B/op 125 allocs/op
|
|
BenchmarkCall_gotba-16 27940 43644 ns/op 11259 B/op 125 allocs/op
|
|
BenchmarkCall_gotba-16 29090 41643 ns/op 11232 B/op 125 allocs/op
|
|
BenchmarkCall_gotba-16 28002 42461 ns/op 11183 B/op 125 allocs/op
|
|
BenchmarkCall_gotba-16 28578 42082 ns/op 11204 B/op 125 allocs/op
|
|
BenchmarkCall_gotba-16 28549 41973 ns/op 11237 B/op 125 allocs/op
|
|
BenchmarkCall_gotba-16 29086 41702 ns/op 11203 B/op 125 allocs/op
|
|
BenchmarkCall_gotba-16 29630 41783 ns/op 11262 B/op 125 allocs/op
|
|
BenchmarkCall_gotba-16 28371 41810 ns/op 11217 B/op 125 allocs/op
|
|
BenchmarkCall_telebot-16 27510 43416 ns/op 13457 B/op 139 allocs/op
|
|
BenchmarkCall_telebot-16 28102 43319 ns/op 13473 B/op 139 allocs/op
|
|
BenchmarkCall_telebot-16 27558 43530 ns/op 13417 B/op 139 allocs/op
|
|
BenchmarkCall_telebot-16 27274 43654 ns/op 13445 B/op 139 allocs/op
|
|
BenchmarkCall_telebot-16 27627 43530 ns/op 13489 B/op 139 allocs/op
|
|
BenchmarkCall_telebot-16 27499 42836 ns/op 13467 B/op 139 allocs/op
|
|
BenchmarkCall_telebot-16 27860 43375 ns/op 13457 B/op 139 allocs/op
|
|
BenchmarkCall_telebot-16 27711 43400 ns/op 13439 B/op 139 allocs/op
|
|
BenchmarkCall_telebot-16 27668 43472 ns/op 13482 B/op 139 allocs/op
|
|
BenchmarkCall_telebot-16 28063 43182 ns/op 13487 B/op 139 allocs/op
|
|
BenchmarkCall_gobot-16 19645 60805 ns/op 13879 B/op 176 allocs/op
|
|
BenchmarkCall_gobot-16 19562 61374 ns/op 13823 B/op 176 allocs/op
|
|
BenchmarkCall_gobot-16 19575 60944 ns/op 13823 B/op 176 allocs/op
|
|
BenchmarkCall_gobot-16 19538 61461 ns/op 13844 B/op 176 allocs/op
|
|
BenchmarkCall_gobot-16 19624 61253 ns/op 13806 B/op 176 allocs/op
|
|
BenchmarkCall_gobot-16 19617 61127 ns/op 13824 B/op 176 allocs/op
|
|
BenchmarkCall_gobot-16 19516 61568 ns/op 13775 B/op 176 allocs/op
|
|
BenchmarkCall_gobot-16 19514 61340 ns/op 13828 B/op 176 allocs/op
|
|
BenchmarkCall_gobot-16 19392 60426 ns/op 13863 B/op 176 allocs/op
|
|
BenchmarkCall_gobot-16 23968 49951 ns/op 13844 B/op 176 allocs/op
|
|
BenchmarkCall_telego-16 33622 35493 ns/op 6780 B/op 48 allocs/op
|
|
BenchmarkCall_telego-16 33874 35438 ns/op 6703 B/op 48 allocs/op
|
|
BenchmarkCall_telego-16 34560 35482 ns/op 6704 B/op 48 allocs/op
|
|
BenchmarkCall_telego-16 33298 35830 ns/op 6711 B/op 48 allocs/op
|
|
BenchmarkCall_telego-16 33205 35946 ns/op 6706 B/op 48 allocs/op
|
|
BenchmarkCall_telego-16 33428 35949 ns/op 6707 B/op 48 allocs/op
|
|
BenchmarkCall_telego-16 33452 35974 ns/op 6692 B/op 48 allocs/op
|
|
BenchmarkCall_telego-16 33056 35853 ns/op 6705 B/op 48 allocs/op
|
|
BenchmarkCall_telego-16 33120 35808 ns/op 6703 B/op 48 allocs/op
|
|
BenchmarkCall_telego-16 33450 38996 ns/op 6699 B/op 48 allocs/op
|
|
BenchmarkDispatch_ours-16 12381547 96.05 ns/op 128 B/op 3 allocs/op
|
|
BenchmarkDispatch_ours-16 12636062 99.34 ns/op 128 B/op 3 allocs/op
|
|
BenchmarkDispatch_ours-16 12161170 98.43 ns/op 128 B/op 3 allocs/op
|
|
BenchmarkDispatch_ours-16 12205023 97.90 ns/op 128 B/op 3 allocs/op
|
|
BenchmarkDispatch_ours-16 12590581 98.83 ns/op 128 B/op 3 allocs/op
|
|
BenchmarkDispatch_ours-16 12033376 99.15 ns/op 128 B/op 3 allocs/op
|
|
BenchmarkDispatch_ours-16 12049588 98.48 ns/op 128 B/op 3 allocs/op
|
|
BenchmarkDispatch_ours-16 12324108 98.38 ns/op 128 B/op 3 allocs/op
|
|
BenchmarkDispatch_ours-16 11924947 96.71 ns/op 128 B/op 3 allocs/op
|
|
BenchmarkDispatch_ours-16 11940064 99.26 ns/op 128 B/op 3 allocs/op
|
|
BenchmarkDispatch_telebot-16 4456072 262.5 ns/op 678 B/op 5 allocs/op
|
|
BenchmarkDispatch_telebot-16 4330234 275.3 ns/op 678 B/op 5 allocs/op
|
|
BenchmarkDispatch_telebot-16 4478779 268.7 ns/op 679 B/op 5 allocs/op
|
|
BenchmarkDispatch_telebot-16 4394821 282.5 ns/op 678 B/op 5 allocs/op
|
|
BenchmarkDispatch_telebot-16 4376773 271.6 ns/op 679 B/op 5 allocs/op
|
|
BenchmarkDispatch_telebot-16 4516370 268.7 ns/op 678 B/op 5 allocs/op
|
|
BenchmarkDispatch_telebot-16 4465942 276.0 ns/op 678 B/op 5 allocs/op
|
|
BenchmarkDispatch_telebot-16 4399328 270.1 ns/op 679 B/op 5 allocs/op
|
|
BenchmarkDispatch_telebot-16 4531597 268.3 ns/op 679 B/op 5 allocs/op
|
|
BenchmarkDispatch_telebot-16 4376616 272.3 ns/op 679 B/op 5 allocs/op
|
|
BenchmarkDispatch_gobot-16 4911369 249.4 ns/op 48 B/op 1 allocs/op
|
|
BenchmarkDispatch_gobot-16 4896456 246.3 ns/op 48 B/op 1 allocs/op
|
|
BenchmarkDispatch_gobot-16 4789376 246.4 ns/op 48 B/op 1 allocs/op
|
|
BenchmarkDispatch_gobot-16 4949206 247.7 ns/op 48 B/op 1 allocs/op
|
|
BenchmarkDispatch_gobot-16 4902912 243.1 ns/op 48 B/op 1 allocs/op
|
|
BenchmarkDispatch_gobot-16 4913300 244.7 ns/op 48 B/op 1 allocs/op
|
|
BenchmarkDispatch_gobot-16 4925991 245.5 ns/op 48 B/op 1 allocs/op
|
|
BenchmarkDispatch_gobot-16 4817457 245.9 ns/op 48 B/op 1 allocs/op
|
|
BenchmarkDispatch_gobot-16 4943328 245.8 ns/op 49 B/op 1 allocs/op
|
|
BenchmarkDispatch_gobot-16 4751266 248.1 ns/op 48 B/op 1 allocs/op
|
|
BenchmarkLargeUnmarshal_ours-16 180361 6682 ns/op 6019 B/op 34 allocs/op
|
|
BenchmarkLargeUnmarshal_ours-16 178388 6765 ns/op 6016 B/op 34 allocs/op
|
|
BenchmarkLargeUnmarshal_ours-16 182600 6701 ns/op 6016 B/op 34 allocs/op
|
|
BenchmarkLargeUnmarshal_ours-16 178785 6710 ns/op 6016 B/op 34 allocs/op
|
|
BenchmarkLargeUnmarshal_ours-16 181588 6726 ns/op 6016 B/op 34 allocs/op
|
|
BenchmarkLargeUnmarshal_ours-16 177378 6730 ns/op 6016 B/op 34 allocs/op
|
|
BenchmarkLargeUnmarshal_ours-16 181004 6729 ns/op 6016 B/op 34 allocs/op
|
|
BenchmarkLargeUnmarshal_ours-16 176672 6682 ns/op 6016 B/op 34 allocs/op
|
|
BenchmarkLargeUnmarshal_ours-16 184182 6726 ns/op 6016 B/op 34 allocs/op
|
|
BenchmarkLargeUnmarshal_ours-16 179983 6813 ns/op 6016 B/op 34 allocs/op
|
|
BenchmarkLargeUnmarshal_gotba-16 138108 8579 ns/op 3520 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_gotba-16 148593 8143 ns/op 3520 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_gotba-16 147964 8075 ns/op 3520 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_gotba-16 147601 8161 ns/op 3520 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_gotba-16 148257 8020 ns/op 3520 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_gotba-16 150858 8058 ns/op 3519 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_gotba-16 149251 8040 ns/op 3520 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_gotba-16 151614 8054 ns/op 3520 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_gotba-16 152306 8050 ns/op 3519 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_gotba-16 152979 8094 ns/op 3520 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_telebot-16 119103 10113 ns/op 5728 B/op 60 allocs/op
|
|
BenchmarkLargeUnmarshal_telebot-16 115418 10247 ns/op 5728 B/op 60 allocs/op
|
|
BenchmarkLargeUnmarshal_telebot-16 116160 10260 ns/op 5728 B/op 60 allocs/op
|
|
BenchmarkLargeUnmarshal_telebot-16 117031 10346 ns/op 5728 B/op 60 allocs/op
|
|
BenchmarkLargeUnmarshal_telebot-16 116731 10311 ns/op 5728 B/op 60 allocs/op
|
|
BenchmarkLargeUnmarshal_telebot-16 121227 10135 ns/op 5728 B/op 60 allocs/op
|
|
BenchmarkLargeUnmarshal_telebot-16 119989 10178 ns/op 5728 B/op 60 allocs/op
|
|
BenchmarkLargeUnmarshal_telebot-16 119311 10194 ns/op 5728 B/op 60 allocs/op
|
|
BenchmarkLargeUnmarshal_telebot-16 119388 10183 ns/op 5728 B/op 60 allocs/op
|
|
BenchmarkLargeUnmarshal_telebot-16 120195 10133 ns/op 5728 B/op 60 allocs/op
|
|
BenchmarkLargeUnmarshal_gobot-16 146700 8235 ns/op 4817 B/op 50 allocs/op
|
|
BenchmarkLargeUnmarshal_gobot-16 147666 8230 ns/op 4816 B/op 50 allocs/op
|
|
BenchmarkLargeUnmarshal_gobot-16 148058 8212 ns/op 4816 B/op 50 allocs/op
|
|
BenchmarkLargeUnmarshal_gobot-16 148092 8210 ns/op 4816 B/op 50 allocs/op
|
|
BenchmarkLargeUnmarshal_gobot-16 146656 8208 ns/op 4816 B/op 50 allocs/op
|
|
BenchmarkLargeUnmarshal_gobot-16 148036 8259 ns/op 4816 B/op 50 allocs/op
|
|
BenchmarkLargeUnmarshal_gobot-16 146211 8287 ns/op 4816 B/op 50 allocs/op
|
|
BenchmarkLargeUnmarshal_gobot-16 146793 8279 ns/op 4816 B/op 50 allocs/op
|
|
BenchmarkLargeUnmarshal_gobot-16 146083 8232 ns/op 4816 B/op 50 allocs/op
|
|
BenchmarkLargeUnmarshal_gobot-16 147385 8221 ns/op 4816 B/op 50 allocs/op
|
|
BenchmarkLargeUnmarshal_telego-16 150852 8155 ns/op 6762 B/op 31 allocs/op
|
|
BenchmarkLargeUnmarshal_telego-16 152559 8040 ns/op 6758 B/op 31 allocs/op
|
|
BenchmarkLargeUnmarshal_telego-16 146462 7989 ns/op 6757 B/op 31 allocs/op
|
|
BenchmarkLargeUnmarshal_telego-16 154480 7842 ns/op 6759 B/op 31 allocs/op
|
|
BenchmarkLargeUnmarshal_telego-16 155208 7811 ns/op 6759 B/op 31 allocs/op
|
|
BenchmarkLargeUnmarshal_telego-16 149310 7848 ns/op 6759 B/op 31 allocs/op
|
|
BenchmarkLargeUnmarshal_telego-16 156939 7835 ns/op 6757 B/op 31 allocs/op
|
|
BenchmarkLargeUnmarshal_telego-16 154064 7867 ns/op 6759 B/op 31 allocs/op
|
|
BenchmarkLargeUnmarshal_telego-16 153975 7849 ns/op 6758 B/op 31 allocs/op
|
|
BenchmarkLargeUnmarshal_telego-16 152520 7811 ns/op 6758 B/op 31 allocs/op
|
|
BenchmarkLargeUnmarshal_echotron-16 145399 8167 ns/op 4323 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_echotron-16 147351 8124 ns/op 4319 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_echotron-16 148053 8094 ns/op 4320 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_echotron-16 147170 8124 ns/op 4320 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_echotron-16 147792 8092 ns/op 4320 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_echotron-16 145971 8105 ns/op 4320 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_echotron-16 148708 8122 ns/op 4320 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_echotron-16 147525 8105 ns/op 4320 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_echotron-16 148635 8165 ns/op 4320 B/op 56 allocs/op
|
|
BenchmarkLargeUnmarshal_echotron-16 150871 8124 ns/op 4320 B/op 56 allocs/op
|
|
BenchmarkWebhook_ours-16 705109 1911 ns/op 2232 B/op 11 allocs/op
|
|
BenchmarkWebhook_ours-16 651456 1911 ns/op 2232 B/op 11 allocs/op
|
|
BenchmarkWebhook_ours-16 683557 1875 ns/op 2232 B/op 11 allocs/op
|
|
BenchmarkWebhook_ours-16 668317 1830 ns/op 2232 B/op 11 allocs/op
|
|
BenchmarkWebhook_ours-16 703718 1833 ns/op 2232 B/op 11 allocs/op
|
|
BenchmarkWebhook_ours-16 707150 1844 ns/op 2232 B/op 11 allocs/op
|
|
BenchmarkWebhook_ours-16 700472 1810 ns/op 2232 B/op 11 allocs/op
|
|
BenchmarkWebhook_ours-16 699192 1828 ns/op 2232 B/op 11 allocs/op
|
|
BenchmarkWebhook_ours-16 671794 1828 ns/op 2232 B/op 11 allocs/op
|
|
BenchmarkWebhook_ours-16 687226 1826 ns/op 2232 B/op 11 allocs/op
|
|
BenchmarkWebhook_gotba-16 544628 2080 ns/op 1496 B/op 17 allocs/op
|
|
BenchmarkWebhook_gotba-16 565494 2081 ns/op 1496 B/op 17 allocs/op
|
|
BenchmarkWebhook_gotba-16 579736 2081 ns/op 1496 B/op 17 allocs/op
|
|
BenchmarkWebhook_gotba-16 581365 2082 ns/op 1496 B/op 17 allocs/op
|
|
BenchmarkWebhook_gotba-16 580501 2075 ns/op 1496 B/op 17 allocs/op
|
|
BenchmarkWebhook_gotba-16 582160 2091 ns/op 1496 B/op 17 allocs/op
|
|
BenchmarkWebhook_gotba-16 563130 2089 ns/op 1496 B/op 17 allocs/op
|
|
BenchmarkWebhook_gotba-16 573872 2088 ns/op 1496 B/op 17 allocs/op
|
|
BenchmarkWebhook_gotba-16 569616 2093 ns/op 1496 B/op 17 allocs/op
|
|
BenchmarkWebhook_gotba-16 599923 2069 ns/op 1496 B/op 17 allocs/op
|
|
BenchmarkWebhook_telebot-16 562394 2162 ns/op 1816 B/op 17 allocs/op
|
|
BenchmarkWebhook_telebot-16 562137 2272 ns/op 1816 B/op 17 allocs/op
|
|
BenchmarkWebhook_telebot-16 488323 2220 ns/op 1816 B/op 17 allocs/op
|
|
BenchmarkWebhook_telebot-16 538561 2199 ns/op 1816 B/op 17 allocs/op
|
|
BenchmarkWebhook_telebot-16 581037 2187 ns/op 1816 B/op 17 allocs/op
|
|
BenchmarkWebhook_telebot-16 540055 2213 ns/op 1816 B/op 17 allocs/op
|
|
BenchmarkWebhook_telebot-16 546921 2203 ns/op 1816 B/op 17 allocs/op
|
|
BenchmarkWebhook_telebot-16 574988 2188 ns/op 1816 B/op 17 allocs/op
|
|
BenchmarkWebhook_telebot-16 588076 2154 ns/op 1816 B/op 17 allocs/op
|
|
BenchmarkWebhook_telebot-16 571617 2181 ns/op 1816 B/op 17 allocs/op
|
|
BenchmarkWebhook_gobot-16 588786 2080 ns/op 1832 B/op 16 allocs/op
|
|
BenchmarkWebhook_gobot-16 551653 2080 ns/op 1832 B/op 16 allocs/op
|
|
BenchmarkWebhook_gobot-16 590686 2084 ns/op 1832 B/op 16 allocs/op
|
|
BenchmarkWebhook_gobot-16 588870 2096 ns/op 1832 B/op 16 allocs/op
|
|
BenchmarkWebhook_gobot-16 606735 2064 ns/op 1832 B/op 16 allocs/op
|
|
BenchmarkWebhook_gobot-16 597108 2084 ns/op 1832 B/op 16 allocs/op
|
|
BenchmarkWebhook_gobot-16 600633 2069 ns/op 1832 B/op 16 allocs/op
|
|
BenchmarkWebhook_gobot-16 589102 2110 ns/op 1832 B/op 16 allocs/op
|
|
BenchmarkWebhook_gobot-16 583528 2104 ns/op 1832 B/op 16 allocs/op
|
|
BenchmarkWebhook_gobot-16 599022 2073 ns/op 1832 B/op 16 allocs/op
|
|
BenchmarkWebhook_telego-16 587408 2193 ns/op 3131 B/op 11 allocs/op
|
|
BenchmarkWebhook_telego-16 601533 2152 ns/op 3131 B/op 11 allocs/op
|
|
BenchmarkWebhook_telego-16 584689 2127 ns/op 3131 B/op 11 allocs/op
|
|
BenchmarkWebhook_telego-16 576732 2153 ns/op 3131 B/op 11 allocs/op
|
|
BenchmarkWebhook_telego-16 568095 2143 ns/op 3131 B/op 11 allocs/op
|
|
BenchmarkWebhook_telego-16 553896 2132 ns/op 3131 B/op 11 allocs/op
|
|
BenchmarkWebhook_telego-16 579055 2130 ns/op 3131 B/op 11 allocs/op
|
|
BenchmarkWebhook_telego-16 595776 2144 ns/op 3131 B/op 11 allocs/op
|
|
BenchmarkWebhook_telego-16 573843 2134 ns/op 3131 B/op 11 allocs/op
|
|
BenchmarkWebhook_telego-16 513824 2267 ns/op 3131 B/op 11 allocs/op
|
|
BenchmarkWebhook_echotron-16 587734 2178 ns/op 1720 B/op 16 allocs/op
|
|
BenchmarkWebhook_echotron-16 557188 2039 ns/op 1720 B/op 16 allocs/op
|
|
BenchmarkWebhook_echotron-16 600524 2020 ns/op 1720 B/op 16 allocs/op
|
|
BenchmarkWebhook_echotron-16 602959 2019 ns/op 1720 B/op 16 allocs/op
|
|
BenchmarkWebhook_echotron-16 588694 2048 ns/op 1720 B/op 16 allocs/op
|
|
BenchmarkWebhook_echotron-16 602366 2039 ns/op 1720 B/op 16 allocs/op
|
|
BenchmarkWebhook_echotron-16 604621 2031 ns/op 1720 B/op 16 allocs/op
|
|
BenchmarkWebhook_echotron-16 599146 2037 ns/op 1720 B/op 16 allocs/op
|
|
BenchmarkWebhook_echotron-16 586056 2051 ns/op 1720 B/op 16 allocs/op
|
|
BenchmarkWebhook_echotron-16 598456 2049 ns/op 1720 B/op 16 allocs/op
|
|
PASS
|
|
ok github.com/lukaszraczylo/go-telegram/test/benchmarks 242.858s
|