Documentation

Benchmark

How Clarity compares with the other popular PHP template engines, across four rendering shapes. The two object shapes come first, because they are the same content and the same values held two ways — as objects and as nested arrays — so the difference between them is the cost of the access shape and nothing else. Then the heavy page of escapes and loops, and last the only shape whose iteration nests: 200 items each emitting a label and ten inner spans, which makes it the largest render here rather than a baseline. The main README shows one of these at a glance; this page is the comparison in full.

Generated — do not edit by hand. Every figure below comes from a benchmark run's own JSON and is re-rendered from it, so the numbers cannot drift from the data they came from. To update this page, re-run the harness and re-publish; see the azera-competition repository.

Every engine renders the same template shape, in the same session — a difference between two engines is the engines, a difference between two sections is the work the page does. Compare engines WITHIN a shape; a ranking read across sections ranks the pages, not the engines.

Objects

What the page renders, and so what these figures are the cost of: two properties, a nested object, a nullable property behind a default, and an array inside an object.

Time per render — Objects

Time per render — Objects

Dot: median render · caps: fastest observation and p95 · multiplier: median ÷ the fastest median.

First render — Objects

First render — Objects

The one-off cost of the first request after a deploy: engine boot, template compile, cache write and one render. Measured once per engine, each in its own fresh process; OPcache is on but its CLI segment is per-process, so the engine source is compiled there too.

Memory per run — Objects

Memory per run — Objects

Reads the PHP heap. Left cap: what the engine costs to have loaded, nothing rendered. Dot: what a whole run still holds, after a gc pass — memory_get_usage(false) after a whole run of iterations_per_run renders in a fresh process, gc_collect_cycles() called first. Right cap: the run's high-water mark. Memory probe: a fresh process with opcache.enable_cli=1 but a per-process CLI segment, so engine source is compiled in that process. Every reading is deterministic, so this is not a spread of repeats.

Results — Objects

Generated from the same rows the charts are drawn from. Rows are ordered by median, fastest first.

Engine First render (ms) Mean (ms) Median (ms) Min (ms) p95 (ms) Retained (MB) Peak (MB)
Clarity 30.155 0.084 0.080 0.077 0.106 2.37 2.78
Native 1.252 0.106 0.100 0.096 0.129 1.64 2.15
Plates 3.763 0.116 0.109 0.105 0.143 1.70 2.15
Stempler 66.368 0.121 0.115 0.110 0.146 2.46 2.88
Latte 94.079 0.247 0.237 0.225 0.289 2.91 8.33
Blade 37.986 0.268 0.258 0.242 0.319 3.03 3.34
Twig 63.930 0.420 0.405 0.381 0.495 2.99 3.26

Objects as arrays

What the page renders, and so what these figures are the cost of: the same content in the same order with the same values held as nested arrays, so access shape is the only difference.

Time per render — Objects as arrays

Time per render — Objects as arrays

Dot: median render · caps: fastest observation and p95 · multiplier: median ÷ the fastest median.

First render — Objects as arrays

First render — Objects as arrays

The one-off cost of the first request after a deploy: engine boot, template compile, cache write and one render. Measured once per engine, each in its own fresh process; OPcache is on but its CLI segment is per-process, so the engine source is compiled there too.

Memory per run — Objects as arrays

Memory per run — Objects as arrays

Reads the PHP heap. Left cap: what the engine costs to have loaded, nothing rendered. Dot: what a whole run still holds, after a gc pass — memory_get_usage(false) after a whole run of iterations_per_run renders in a fresh process, gc_collect_cycles() called first. Right cap: the run's high-water mark. Memory probe: a fresh process with opcache.enable_cli=1 but a per-process CLI segment, so engine source is compiled in that process. Every reading is deterministic, so this is not a spread of repeats.

Results — Objects as arrays

Generated from the same rows the charts are drawn from. Rows are ordered by median, fastest first.

Engine First render (ms) Mean (ms) Median (ms) Min (ms) p95 (ms) Retained (MB) Peak (MB)
Clarity 31.524 0.086 0.081 0.079 0.109 2.43 3.19
Native 1.260 0.109 0.103 0.097 0.136 1.69 2.15
Plates 3.806 0.116 0.109 0.105 0.142 1.76 2.15
Stempler 65.744 0.124 0.118 0.112 0.147 2.51 2.93
Latte 95.980 0.251 0.241 0.229 0.294 2.97 8.40
Blade 39.877 0.272 0.263 0.246 0.325 3.09 3.39
Twig 66.170 0.359 0.347 0.327 0.419 3.04 3.31

Mixed

What the page renders, and so what these figures are the cost of: the heavy page: 20 flat variables each read twice (as text and as a data-value attribute) plus 20 rows of six fields each, over 40 flat variable accesses per render and 1440 in total at 200 items, with every value HTML-special so the escape path does real work in both the body and an attribute context.

Time per render — Mixed

Time per render — Mixed

Dot: median render · caps: fastest observation and p95 · multiplier: median ÷ the fastest median.

First render — Mixed

First render — Mixed

The one-off cost of the first request after a deploy: engine boot, template compile, cache write and one render. Measured once per engine, each in its own fresh process; OPcache is on but its CLI segment is per-process, so the engine source is compiled there too.

Memory per run — Mixed

Memory per run — Mixed

Reads the PHP heap. Left cap: what the engine costs to have loaded, nothing rendered. Dot: what a whole run still holds, after a gc pass — memory_get_usage(false) after a whole run of iterations_per_run renders in a fresh process, gc_collect_cycles() called first. Right cap: the run's high-water mark. Memory probe: a fresh process with opcache.enable_cli=1 but a per-process CLI segment, so engine source is compiled in that process. Every reading is deterministic, so this is not a spread of repeats.

Results — Mixed

Generated from the same rows the charts are drawn from. Rows are ordered by median, fastest first.

Engine First render (ms) Mean (ms) Median (ms) Min (ms) p95 (ms) Retained (MB) Peak (MB)
Clarity 45.687 0.280 0.271 0.255 0.329 2.48 3.56
Native 1.724 0.315 0.306 0.290 0.363 1.73 2.79
Stempler 80.991 0.334 0.324 0.309 0.381 2.59 3.26
Plates 5.160 0.354 0.343 0.318 0.409 1.80 2.65
Latte 114.322 0.456 0.440 0.416 0.521 3.02 11.15
Blade 41.218 0.569 0.557 0.514 0.651 3.13 3.46
Twig 93.340 0.635 0.614 0.583 0.732 3.09 4.75

Nested loops

What the page renders, and so what these figures are the cost of: a layout, an included partial, a loop over 200 items that each emit a filtered label and a nested loop of ten spans — the only shape whose iteration nests, and so the largest render in the set.

Time per render — Nested loops

Time per render — Nested loops

Dot: median render · caps: fastest observation and p95 · multiplier: median ÷ the fastest median.

First render — Nested loops

First render — Nested loops

The one-off cost of the first request after a deploy: engine boot, template compile, cache write and one render. Measured once per engine, each in its own fresh process; OPcache is on but its CLI segment is per-process, so the engine source is compiled there too.

Memory per run — Nested loops

Memory per run — Nested loops

Reads the PHP heap. Left cap: what the engine costs to have loaded, nothing rendered. Dot: what a whole run still holds, after a gc pass — memory_get_usage(false) after a whole run of iterations_per_run renders in a fresh process, gc_collect_cycles() called first. Right cap: the run's high-water mark. Memory probe: a fresh process with opcache.enable_cli=1 but a per-process CLI segment, so engine source is compiled in that process. Every reading is deterministic, so this is not a spread of repeats.

Results — Nested loops

Generated from the same rows the charts are drawn from. Rows are ordered by median, fastest first.

Engine First render (ms) Mean (ms) Median (ms) Min (ms) p95 (ms) Retained (MB) Peak (MB)
Clarity 30.039 0.357 0.346 0.324 0.413 2.35 2.76
Native 1.446 0.408 0.396 0.373 0.468 1.61 2.15
Plates 3.636 0.439 0.423 0.400 0.511 1.68 2.56
Stempler 59.878 0.439 0.425 0.400 0.504 2.42 2.84
Latte 86.589 0.629 0.605 0.577 0.725 2.88 8.56
Blade 39.208 0.672 0.648 0.611 0.777 3.01 3.49
Twig 61.666 1.074 1.039 0.988 1.248 2.93 3.62

What the columns are

  • First render — the first request after a deploy, in a fresh process per engine: boot, compile, cache write, one render. The template cache is cold.
  • Mean / Median / Min / p95 — over every individual render across all runs.
  • Retained — heap still held after a whole run, after a gc pass, in a fresh process.
  • Peak — the same run's high-water mark, where the first compile's transient allocation lives. Not a second measurement of Retained.

A few percent is a tie, not a win: it is within a single engine's own run-to-run spread.

Environment — PHP 8.5.11 · Linux 6.8.0-139-generic · SAPI cli · OPcache (opcache.enable_cli): yes · JIT: tracing (buffer 64M) · Clarity template revalidate: 60 s

Budget — 10,000 renders × 30 runs, 200 items per render

Method — Steady-state timings: the render loop for each (engine, page) cell runs in its own fresh process against a warm cache: one untimed warm-up render, then runs x iterations-per-run timed renders. No order: each (engine, page) cell is measured in its own process, so measurement order cannot affect a cell. The first render was measured as one render in a fresh process with a cold template cache: engine class loading, template compile, cache write and one render.

Engines — Clarity dev-main (v0.7.0-1-g95e2339) · NativeEngine (Azera) dev-main (v0.7.0-3-gcd7a45d) · Plates 3.6.0 · Blade 12.69.2 · Twig 3.27.0 · Stempler 3.17.2 · Latte 3.1.6

Measured 2026-12-02T17:33:17+00:00

The full published report, including the headline page: https://sailantis.github.io/azera-competition/benchmarks/view-engine.html