欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

浅谈Java模板引擎性能对比

程序员文章站 2024-02-28 22:27:46
从github上翻到对jsp、thymeleaf 3、velocity 1.7、freemarker 2.3.23几款主流模板的性能对比,总体上看,freemarker、v...

从github上翻到对jsp、thymeleaf 3、velocity 1.7、freemarker 2.3.23几款主流模板的性能对比,总体上看,freemarker、velocity、jsp在性能上差别不大,而thymeleaf与前三者相比,在性能上存在较大的差距,因此,选择thymeleaf作为模板引擎需要慎重。

 参考:

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

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

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。