Skip to content

Performance

gsx renders by streaming HTML straight to your io.Writer — no intermediate document, no per-component buffer pool. Generated code is direct write calls, and the escaper writes safe runs in place, so rendering allocates very little.

Reproduce

The benchmark source lives at github.com/gsxhq/gsx-bench.

sh
git clone https://github.com/gsxhq/gsx-bench
cd gsx-bench
go test -bench . -benchmem

The numbers below are a snapshot from Apple M3 Ultra with Go 1.26.1. Treat them as directional; use the command above on your hardware for local decisions.

Numbers

Apple M3 Ultra, Go 1.26.1, rendering into a pooled bytes.Buffer (as an HTTP handler would). Lower is better.

The same small template through all three engines:

enginetimeallocs
gsx270 ns2
templ394 ns10
html/template1428 ns24

A realistic, component- and class-heavy page (20 rows, nested components):

enginetimeallocs
gsx4.7 µs62
templ6.8 µs204

Escaping-heavy content (bodies full of < > & " ') — gsx's html/template-derived escaper never allocates:

enginetimeallocs
gsx3.6 µs1
templ6.6 µs143

Notes

  • In this benchmark snapshot, gsx is faster than html/template and templ with fewer allocations.
  • Numbers are machine- and version-specific.