因此,我想提出一个类似的基准测试。我使用了Twitter引导程序示例页面,并将其转换为xhtml strict。之后,我只设置了一个ApplicationScoped CDI bean,它返回了Hello,World。我将EL表达式放在页面上。对于JSF版本,我使用了JSF资源处理程序,对于JSPX版本,我使用了HTML样式css和js includes。
我使用apache Bench来测试主页加载时间。该测试是在未优化的TomEE + v1.5.2服务器上执行的。我将每个基准测试运行了5倍,然后在测量之前运行了完整的GC。在同一JVM实例中完成了Bost测试,而没有重新启动JVM。我在libpath上有可用的APR,但是我不确定这会影响此测试。
JSF速度较慢,但不是很慢,因为我们处理的数量很少。什么是不能证明是由于网页变得越来越复杂,确实JSF / JSPX规模的线性或指数。
我注意到的一件事是,与JSF相比,JSPX产生的垃圾很少。在JSPX页面上运行基准测试会导致使用的堆从184mb跃升到237mb。在JSF页面上的同一JVM中运行基准测试会导致使用的堆从108mb跃升到至少 404mb,但是此时会启动自动垃圾回收。似乎绝对有必要针对JSF调整垃圾收集器。
JSF
jonfisher@peanut:~$ /usr/local/bin/ab -n 10000 -c 100 http://localhost:8080/cdi-jsp/index.jsf
This is ApacheBench, Version 2.3 <$Revision: 1373084 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: Apache-Coyote/1.1
Server Hostname: localhost
Server Port: 8080
Document Path: /cdi-jsp/index.jsf
Document Length: 2904 bytes
Concurrency Level: 100
Time taken for tests: 2.138 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 32160000 bytes
HTML transferred: 29040000 bytes
Requests per second: 4677.27 [#/sec] (mean)
Time per request: 21.380 [ms] (mean)
Time per request: 0.214 [ms] (mean, across all concurrent requests)
Transfer rate: 14689.55 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 1.3 1 21
Processing: 1 20 9.0 18 63
Waiting: 1 19 8.8 17 62
Total: 2 21 8.8 20 64
Percentage of the requests served within a certain time (ms)
50% 20
66% 23
75% 25
80% 27
90% 32
95% 39
98% 46
99% 50
100% 64 (longest request)
JSPX
jonfisher@peanut:~$ /usr/local/bin/ab -n 10000 -c 100 http://localhost:8080/cdi-jsp/page2.jspx
This is ApacheBench, Version 2.3 <$Revision: 1373084 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: Apache-Coyote/1.1
Server Hostname: localhost
Server Port: 8080
Document Path: /cdi-jsp/page2.jspx
Document Length: 2440 bytes
Concurrency Level: 100
Time taken for tests: 1.273 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 26290000 bytes
HTML transferred: 24400000 bytes
Requests per second: 7856.63 [#/sec] (mean)
Time per request: 12.728 [ms] (mean)
Time per request: 0.127 [ms] (mean, across all concurrent requests)
Transfer rate: 20170.98 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 5 2.3 6 20
Processing: 1 8 4.6 6 40
Waiting: 1 8 4.3 6 40
Total: 2 13 3.8 12 41
Percentage of the requests served within a certain time (ms)
50% 12
66% 12
75% 13
80% 13
90% 17
95% 20
98% 24
99% 28
100% 41 (longest request)