jreijn/spring-comparing-template-engines

Freemarker 2.3.23 vs Thymeleaf 3.0.0BETA02 vs Velocity 1.7 vs JSP (latest builds as of March, 2016)

Closed this issue · 5 comments

Freemarker 2.3.23 vs Thymeleaf 3.0.0BETA02 vs Velocity 1.7 vs JSP (latest builds as of March, 2016)

I updated the POM to reflect the latest releases of Freemarker (2.3.23). I considered the beta release of Thymeleaf as they claim a significant performance boost. Velocity & JSP are the same as before. I have attached the changes I had to make to a few files to run the latest builds. I used ApacheBench v2.3. If you plan on running the tests, make sure you restart Tomcat each time, before running. Here are the results:-

JSP
Document Path: /jsp
Document Length: 8515 bytes
Concurrency Level: 25
Time taken for tests: 13.003 seconds
Complete requests: 25000
Failed requests: 0
Keep-Alive requests: 0
Total transferred: 218825000 bytes
HTML transferred: 212875000 bytes
Requests per second: 1922.59 (#/sec) (mean)
Time per request: 13.003 (ms) (mean)
Time per request: 0.520 (ms) (mean, across all concurrent requests)
Transfer rate: 16434.05 (Kbytes/sec) received

Thymeleaf 3
Document Path: /thymeleaf
Document Length: 8849 bytes
Concurrency Level: 25
Time taken for tests: 23.303 seconds
Complete requests: 25000
Failed requests: 0
Keep-Alive requests: 0
Total transferred: 225300000 bytes
HTML transferred: 221225000 bytes
Requests per second: 1072.80 (#/sec) (mean)
Time per request: 23.303 (ms) (mean)
Time per request: 0.932 (ms) (mean, across all concurrent requests)
Transfer rate: 9441.52 (Kbytes/sec) received

Velocity 1.7
Document Path: /velocity
Document Length: 8951 bytes
Concurrency Level: 25
Time taken for tests: 13.200 seconds
Complete requests: 25000
Failed requests: 0
Keep-Alive requests: 0
Total transferred: 227975000 bytes
HTML transferred: 223775000 bytes
Requests per second: 1893.92 (#/sec) (mean)
Time per request: 13.200 (ms) (mean)
Time per request: 0.528 (ms) (mean, across all concurrent requests)
Transfer rate: 16865.88 (Kbytes/sec) received

Freemarker 2.3.23
Document Path: /freemarker
Document Length: 9035 bytes
Concurrency Level: 25
Time taken for tests: 12.988 seconds
Complete requests: 25000
Failed requests: 0
Keep-Alive requests: 0
Total transferred: 230075000 bytes
HTML transferred: 225875000 bytes
Requests per second: 1924.83 (#/sec) (mean)
Time per request: 12.988 (ms) (mean)
Time per request: 0.520 (ms) (mean, across all concurrent requests)
Transfer rate: 17299.01 (Kbytes/sec) received

My system configuration:-
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 2
Core(s) per socket: 2
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 37
Model name: Intel(R) Core(TM) i5 CPU M 430 @ 2.27GHz
Stepping: 2
CPU MHz: 1199.000
CPU max MHz: 2267.0000
CPU min MHz: 1199.0000
BogoMIPS: 4522.04
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 3072K
NUMA node0 CPU(s): 0-3

updatedFilesForLatestBuilds.zip

Thanks a lot for the feedback and test. I'll see if I can incorporate your changes in the project.

i was found that freemarker is the best selected,is right?

Well, what is 'best' completely depends on the situation. Freemarker seems to be really fast in several tests, but keep in mind that between Freemarker, JSP and velocity the speed difference is not that big (less than a second difference over 25.000 requests). Thymeleaf is on the other hand slower, but it does have a lot of nice features like natural templating, etc. It all comes down to what you need.

Thank you very much. It is very useful