springmvc+freemarker与servlet性能对比

为了更好的测试公平性,刚才的message.flt去空格改为

 

<html><body><p>This is my message:<br> ${message}</p></body></html>

 

 
 编写servlet
package com.ab.test;

import java.io.IOException;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ABTestServlet extends HttpServlet{
public void service(HttpServletRequest request, HttpServletResponse response)
throws IOException {
String message = (String) request.getParameter(&quot;message&quot;);
ServletOutputStream out = response.getOutputStream();
out.print(&quot;This is my message: &quot;+message+&quot;&quot;);
}
}

 

然后用ab测试

环境为我的笔记本T420 i5 560m 4G xp系统resin开1g内存

servlet多次都为这个

D:\TDDOWNLOAD&gt;ab -n 10000 -c 60 http://www.lantii.com/abtest?message=1111
This is ApacheBench, Version 2.0.41-dev  apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

Benchmarking www.lantii.com (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
Finished 10000 requests


Server Software:        Resin/3.1.10
Server Hostname:        www.lantii.com
Server Port:            80

Document Path:          /abtest?message=1111
Document Length:        61 bytes

Concurrency Level:      60
Time taken for tests:   2.31250 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      1590000 bytes
HTML transferred:       610000 bytes
Requests per second:    4923.08 [#/sec] (mean)
Time per request:       12.188 [ms] (mean)
Time per request:       0.203 [ms] (mean, across all concurrent requests)
Transfer rate:          764.06 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.3      0      15
Processing:     0   11   6.4     15      15
Waiting:        0    8   7.5     15      15
Total:          0   11   6.3     15      15

Percentage of the requests served within a certain time (ms)
  50%     15
  66%     15
  75%     15
  80%     15
  90%     15
  95%     15
  98%     15
  99%     15
100%     15 (longest request)

springmvc多次为


[code=&quot;java&quot;]D:\TDDOWNLOAD&gt;ab -n 10000 -c 60 http://www.lantii.com/message/1111
This is ApacheBench, Version 2.0.41-dev  apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

Benchmarking www.lantii.com (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
Finished 10000 requests


Server Software:        Resin/3.1.10
Server Hostname:        www.lantii.com
Server Port:            80

Document Path:          /message/1111
Document Length:        61 bytes

Concurrency Level:      60
Time taken for tests:   3.187500 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      2020000 bytes
HTML transferred:       610000 bytes
Requests per second:    3137.26 [#/sec] (mean)
Time per request:       19.125 [ms] (mean)
Time per request:       0.319 [ms] (mean, across all concurrent requests)
Transfer rate:          618.67 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.5      0      15
Processing:     0   18   6.8     15      46
Waiting:        0   17   6.4     15      46
Total:          0   18   6.8     15      46

Percentage of the requests served within a certain time (ms)
  50%     15
  66%     15
  75%     15
  80%     31
  90%     31
  95%     31
  98%     31
  99%     31
100%     46 (longest request)

看来spring mvc的性能确实还不错

 

你可能感兴趣的:(apache,C++,freemarker,servlet,C#)