从Github上翻到对JSP、Thymeleaf 3、Velocity 1.7、Freemarker 2.3.23几款主流模板的性能对比,总体上看,Freemarker、Velocity、JSP在性能上差别不大,而Thymeleaf与前三者相比,在性能上存在较大的差距,因此,选择Thymeleaf作为模板引擎需要慎重。
参考:https://github.com/jreijn/spring-comparing-template-engines/issues/19
System Configuration
Architecture: x86_64CPU op-mode(s): 32-bit, 64-bitByte Order: Little EndianCPU(s): 4On-line CPU(s) list: 0-3Thread(s) per core: 2Core(s) per socket: 2Socket(s): 1NUMA node(s): 1Vendor ID: GenuineIntelCPU family: 6Model: 37Model name: Intel(R) Core(TM) i5 CPU M 430 @ 2.27GHzStepping: 2CPU MHz: 1199.000CPU max MHz: 2267.0000CPU min MHz: 1199.0000BogoMIPS: 4522.04Virtualization: VT-xL1d cache: 32KL1i cache: 32KL2 cache: 256KL3 cache: 3072KNUMA node0 CPU(s): 0-3
JSP
Document Path: /jspDocument Length: 8515 bytesConcurrency Level: 25Time taken for tests: 13.003 secondsComplete requests: 25000Failed requests: 0Keep-Alive requests: 0Total transferred: 218825000 bytesHTML transferred: 212875000 bytesRequests 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: /thymeleafDocument Length: 8849 bytesConcurrency Level: 25Time taken for tests: 23.303 secondsComplete requests: 25000Failed requests: 0Keep-Alive requests: 0Total transferred: 225300000 bytesHTML transferred: 221225000 bytesRequests 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: /velocityDocument Length: 8951 bytesConcurrency Level: 25Time taken for tests: 13.200 secondsComplete requests: 25000Failed requests: 0Keep-Alive requests: 0Total transferred: 227975000 bytesHTML transferred: 223775000 bytesRequests 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: /freemarkerDocument Length: 9035 bytesConcurrency Level: 25Time taken for tests: 12.988 secondsComplete requests: 25000Failed requests: 0Keep-Alive requests: 0Total transferred: 230075000 bytesHTML transferred: 225875000 bytesRequests 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
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。