Benchmarks¶
Numbers for orientation, not a ranking. Engines differ in features that cost time (Thymeleaf's natural templating, for example), and your pages are not ours. Measure your own pages before deciding anything.
At a glance, Looma 0.1.3 against Thymeleaf 3.1.5 on a 2-CPU server. Pick a page:
Light page · a list of 20 projects, 2.5 KB
Medium page · a 50-row table with a component per row, 12.6 KB
Heavy page · a dashboard over 100 projects, 320 KB
The more a page does (loops, components, formatted values), the larger the gap. On very small pages, Spring MVC, Spring Security and the network take most of the time in both engines.
1. Real pages on a small server¶
A Spring Boot application with each page written for both engines, served over HTTP to a logged-in user, the way a real application runs.
Server: one Docker container limited to 2 CPUs and 4 GB of memory, Java 25 (Eclipse Temurin), G1 garbage collector, heap at 75% of the container's memory. Spring Boot 3.5.16 with Spring Security 6.5, Looma 0.1.3, Thymeleaf 3.1.5 with its Spring Security extras. Template caches on in both engines.
Load: k6 in a separate container on the same Docker network, so the load generator never uses the server's CPUs. Each engine is warmed up first, then each measurement runs 30 seconds, alternating engines. CPU time comes from the container's own accounting. Every request returned 200 and the server logged no errors.
The pages produce the same HTML in both engines (checked before measuring: same text, same tags and attributes):
| Page | What it contains | Size |
|---|---|---|
| Light | Layout and navigation, a list of 20 projects with a link, the owner and one condition | 2.5 KB |
| Medium | Layout and navigation, a 50-row table: currency, dates, initials, plurals, a status badge component per row, odd and even rows, pagination | 12.6 KB |
| Heavy | Layout and navigation, a dashboard over 100 projects and their tasks and comments: components with named slots, includes, nested loops, grouping and sorting, permission checks, a stack, about 30 formatting helpers per project | 320 KB |
Formatting that Thymeleaf has no built-in for (currency with a code, initials, plurals...) goes through a Spring bean that calls the same helper classes Looma uses, so both pages produce identical text.
Results¶
| Page | Concurrent users | Looma pages/s | Thymeleaf pages/s | Looma median | Thymeleaf median |
|---|---|---|---|---|---|
| Light | 2 | 9,717 | 5,905 | 0.16 ms | 0.29 ms |
| Light | 8 | 21,964 | 6,755 | 0.23 ms | 0.51 ms |
| Light | 32 | 25,726 | 7,130 | 0.68 ms | 1.63 ms |
| Medium | 2 | 5,266 | 1,372 | 0.32 ms | 1.35 ms |
| Medium | 8 | 7,355 | 1,150 | 0.48 ms | 2.18 ms |
| Medium | 32 | 7,211 | 1,019 | 1.61 ms | 8.95 ms |
| Heavy | 2 | 340 | 48 | 5.6 ms | 39.6 ms |
| Heavy | 8 | 304 | 35 | 8.8 ms | 205 ms |
| Heavy | 32 | 282 | 35 | 102 ms | 898 ms |
How to read it:
- With few users, the server has spare CPU and the page time is what a visitor waits. On the light page both engines answer in well under a millisecond, so Looma's lead there (1.6×) is mostly invisible.
- Once the 2 CPUs are busy (8 and 32 users), throughput is set by the CPU each page costs, and requests that cannot be served at once wait in line. That is where the difference is felt: the heavy page takes 9 ms with Looma and 205 ms with Thymeleaf at 8 users.
- The slowest requests (95th percentile, not shown) rise to about 80 ms for Looma under full load because Docker pauses a container that has used up its CPU share for the moment; the same applies to Thymeleaf.
2. The heavy page on a laptop¶
The same application without container limits, on an Apple M2 Pro (12 cores), load from k6 on the same machine, 8 concurrent users, 30-second runs after warm-up:
| Looma | Thymeleaf | |
|---|---|---|
| Pages per second | 960 | 150 |
| Median page time | 8.5 ms | 50 ms |
| CPU per page | 5 ms | 50 ms |
3. The engines alone (JMH)¶
The same small table in each engine (a loop, an escaped value, a conditional and the loop counter per row), rendered in-process, warm, templates cached, byte-identical output (checked before measuring). Average time per render over 2 forks × 6 iterations; error margins under 1%. Apple M2 Pro, OpenJDK 25.0.4, Thymeleaf 3.1.5, Pebble 4.1.2.
| Rows | Looma | Pebble | Thymeleaf |
|---|---|---|---|
| 10 | 2.6 µs | 4.2 µs | 12.0 µs |
| 200 | 49.4 µs | 86.4 µs | 227.8 µs |
On this simple table Looma is about 1.7× faster than Pebble and 4.6× faster than Thymeleaf. A table this simple was already fast in earlier versions; the work below matters most on real pages.
What makes Looma fast¶
The heavy page, slowed down about 120 times. Each bar is the CPU work for one page: 6.6 ms with Looma, 58 ms with Thymeleaf. The labels show what each engine does on every request.
- Static HTML is prepared once. A template is split into text and directives when it is first loaded; rendering
copies the text as is. Thymeleaf processes the page tag by tag on every render, looking for
th:attributes. - Expressions are evaluated directly (0.1.3). Spring's SpEL rebuilds type information on every property read
and resolves methods by reflection; on real pages it took nearly half of the time. Looma now evaluates the
common expression shapes itself (variables, getters and records, method calls, arithmetic, comparisons,
conditions,
??, inline lists and maps) with SpEL's exact rules and the same sandbox. Anything else goes to SpEL one step at a time, so results and error messages are identical and every getter or method runs once. About 16,000 expressions are compared against SpEL in the test suite. - Formats are reused (0.1.3). Number, currency and date formats are built once per locale and copied, getter
lookups for
List.sortByand friends are cached, and word splitting no longer uses regular expressions. - Variables and components are cheap. Variables live in a small scope instead of being looked up through the servlet request, and components are pre-parsed templates.
- Earlier (0.1.0): simple property reads skip SpEL, loops reuse their
loopobject, numbers skip escaping and escaping copies untouched text in bulk.
Reproduce¶
The engine benchmark is in this repository:
mvn -Pbench -pl looma-bench -am package -DskipTests
mvn -Pbench -pl looma-bench dependency:build-classpath -Dmdep.outputFile=/tmp/cp.txt
java -cp looma-bench/target/classes:looma-core/target/classes:$(cat /tmp/cp.txt) org.openjdk.jmh.Main EngineBenchmark
The HTTP test runs the application in a container started like this, and drives it from a k6 container on the same network: