Freemarker vs Raw Java
I’ve recently been pitting Freemarker against Raw Java of late because I was under the impression that Freemarker would blow up under load in a multi-threaded environment. Well, it turns out that things aren’t nearly as bad as I’d thought, but it’s still significantly slower than what I’ve been calling “Raw Java”. Here’s the final results with a pretty graph and everything.

Previous test results had shown Freemarker going into the 200 times slower category, but it does actually stay in the 20 times slower category. So, I’m not nearly as freaked out by this as I was a few weeks ago. I still think that the example I’m using, where the FTL is more of a program than a template, that the Raw Java method is nearly as appropriate and positively 20 times faster!
Freemarker vs Raw Java
JVM Version 1.6.0_05-ea
Windows XP[x86] – 2 processors
4.99MB/63.56MB Memory
| Benchmark | Threads | Avg Nanos | Slow Factor |
|---|---|---|---|
| Raw Java | 50 | 1585.19 | 1.00x |
| Raw Java | 30 | 1796.52 | 1.13x |
| Raw Java | 20 | 1862.14 | 1.17x |
| Raw Java | 10 | 1890.36 | 1.19x |
| Raw Java | 60 | 1891.35 | 1.19x |
| Raw Java | 40 | 1891.70 | 1.19x |
| Raw Java | 1 | 2494.68 | 1.57x |
| Freemarker | 10 | 26320.65 | 16.60x |
| Freemarker | 20 | 27597.29 | 17.41x |
| Freemarker | 30 | 28638.00 | 18.07x |
| Freemarker | 40 | 29562.36 | 18.65x |
| Freemarker | 50 | 30019.56 | 18.94x |
| Freemarker | 60 | 31576.83 | 19.92x |
| Freemarker | 1 | 34447.90 | 21.73x |















