Template engine benchmark

Seven engines rendering identical pages — a layout, an included partial, a loop over the items, and nested loops inside it. Clarity and Native are Azera engines; the rest are the template languages Azera adapts.

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.4.2) · NativeEngine (Azera) dev-main (v0.4.1-5-gf9b2de0) · Plates 3.6.0 · Blade 12.69.2 · Twig 3.27.0 · Stempler 3.17.2 · Latte 3.1.6

Measured 2026-11-12T15:15:49+00:00

Scalars

The first rendering shape measured here: a layout, an included partial, a loop over scalars with a filter, and a nested loop inside it. A time here and a time further down are not the same measurement — compare engines WITHIN a page.

Time per render
Time per render

Dot: median render · caps: fastest observation and p95.

First render (fresh process, cold template cache)
First render (fresh process, cold template cache)

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
Memory per run

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.

Results

EngineFirst render (ms)Mean (ms)Median (ms)Min (ms)p95 (ms)Retained (MB)Peak (MB)
Native1.4650.4030.3940.3740.4541.612.15
Clarity24.3610.4140.4040.3830.4682.292.60
Plates3.8090.4310.4210.4000.4871.682.56
Stempler60.9950.4320.4220.4000.4852.422.84
Latte86.5250.6240.6030.5770.7142.888.56
Blade40.0530.6670.6430.6090.7743.013.49
Twig59.3941.0551.0270.9851.1792.933.62

A cell here is the median of one engine's own renders in its own fresh process — not a shared high-water mark.

Mixed

Rendering 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. A figure here and a figure above are different measurements — compare engines within a page, not across pages.

Time per render — Mixed
Time per render — Mixed

Dot: median render · caps: fastest observation and p95.

First render (fresh process, cold template cache) — Mixed
First render (fresh process, cold template cache) — 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.

Results

EngineFirst render (ms)Mean (ms)Median (ms)Min (ms)p95 (ms)Retained (MB)Peak (MB)
Native1.7350.3110.3040.2900.3511.732.79
Clarity34.0710.3120.3040.2900.3522.433.19
Stempler80.5580.3320.3240.3090.3732.593.26
Plates4.8520.3490.3400.3200.3931.802.65
Latte116.4670.4540.4380.4160.5153.0211.15
Blade39.3540.5620.5520.5140.6323.133.46
Twig93.5440.6260.6090.5830.7043.094.75

Objects

Rendering objects instead of scalars: two properties, a nested object, a nullable property behind a default, and an array inside an object. A figure here and a figure above are different measurements — compare engines within a page, not across pages.

Time per render — Objects
Time per render — Objects

Dot: median render · caps: fastest observation and p95.

First render (fresh process, cold template cache) — Objects
First render (fresh process, cold template cache) — 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.

Results

EngineFirst render (ms)Mean (ms)Median (ms)Min (ms)p95 (ms)Retained (MB)Peak (MB)
Clarity24.9940.1010.0970.0930.1202.312.71
Native1.2170.1060.1000.0960.1281.642.15
Plates3.6470.1160.1090.1050.1421.702.15
Stempler65.3740.1200.1150.1090.1412.462.88
Latte95.7300.2460.2360.2260.2832.918.33
Blade38.0390.2640.2560.2420.3073.033.34
Twig66.0780.4160.4050.3820.4792.993.26

Objects as arrays

Rendering the same content in the same order with the same values held as nested arrays, so access shape is the only difference. A figure here and a figure above are different measurements — compare engines within a page, not across pages.

Time per render — Objects as arrays
Time per render — Objects as arrays

Dot: median render · caps: fastest observation and p95.

First render (fresh process, cold template cache) — Objects as arrays
First render (fresh process, cold template cache) — 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.

Results

EngineFirst render (ms)Mean (ms)Median (ms)Min (ms)p95 (ms)Retained (MB)Peak (MB)
Clarity24.1750.1050.1000.0970.1232.372.67
Native1.5970.1070.1020.0970.1271.692.15
Plates3.6500.1160.1100.1050.1431.762.15
Stempler64.5630.1220.1170.1120.1442.512.93
Latte94.1900.2500.2390.2280.2892.978.40
Blade39.9390.2670.2590.2450.3093.093.39
Twig64.0910.3590.3500.3280.4113.043.31