Introduction

My company is currently working on a project based on Thymeleaf 2.1.4. In the forum we found an announcement that Thymeleaf 3 is coming and so we asked ourselves how big the performance change will be between Thymeleaf 2.x and Thymeleaf 3.x.

Also there was a comment about a speed change from 1000 pages per second to 11000 pages per second, but there was no comparison to other template frameworks like Mustache or Freemaker. Therefore we will do a small comparison here.

Benchmark software

For this case we use the template benchmark created by Mitchell Bösecke. The nice thing about this benchmark is, that it also has a few warmup rounds, so that the JVM returns „real“ results.

Note: We have used a SNAPSHOT version, which is something like a alpha/beta version. Therefore treat the results with caution.

Testing machine: Macbook Pro Retina 13 with 8GB RAM and Intel Core i5 with 2.6 GHz.

Benchmark with Thymeleaf 2.1.4.RELEASE

Benchmark Mode Cnt Score Error Units
Freemarker.benchmark thrpt 50 12731,812 ± 145,537 ops/s
Mustache.benchmark thrpt 50 18222,71 ± 205,985 ops/s
Pebble.benchmark thrpt 50 27371,882 ± 392,471 ops/s
Thymeleaf.benchmark thrpt 50 1047,699 ± 32,821 ops/s
Trimou.benchmark thrpt 50 14395,23 ± 535,186 ops/s
Velocity.benchmark thrpt 50 16366,856 ± 209,496 ops/s

Benchmark with Thymeleaf 3.0 Snapshot

Benchmark Mode Cnt Score Error Units
Freemarker.benchmark thrpt 50 13134,939 ± 304,043 ops/s
Mustache.benchmark thrpt 50 18827,112 ± 181,07 ops/s
Pebble.benchmark thrpt 50 27697,279 ± 683,000 ops/s
Thymeleaf.benchmark thrpt 50 2943,03 ± 231,809 ops/s
Trimou.benchmark thrpt 50 15062,598 ± 191,149 ops/s
Velocity.benchmark thrpt 50 16142,213 ± 649,104 ops/s

Conclusion

In our case the benchmark shows an improvement of Thymeleaf 3.0 (Snapshot) being nearly 3 times faster than Thymeleaf 2.1.4. In comparison to the other template engines Thymeleaf is in this use case still slow ;-)