tornado和beego的helloworld性能对比

来源:互联网 发布:教育软件平台公司 编辑:程序博客网 时间:2024/06/08 11:19

测试环境:

windows10虚拟机vmware安装的ubuntu14.04

内存1g,处理器数量2个,每个处理器核心数量1个

测试工具apchebench(ab)

python版本:2.7

tornado版本4.3

go版本1.4

beego版本1.6


tornado helloworld:

import tornado.ioloopimport tornado.webclass MainHandler(tornado.web.RequestHandler):    def get(self):        self.write("hello,world")if __name__ == "__main__":    app = tornado.web.Application(handlers=[(r"/",MainHandler)])    app.listen(8888)    tornado.ioloop.IOLoop.current().start()


ab测试:ab -n 1000 -c 20 http://127.0.0.1:8888/


Benchmarking 127.0.0.1 (be patient)Completed 100 requestsCompleted 200 requestsCompleted 300 requestsCompleted 400 requestsCompleted 500 requestsCompleted 600 requestsCompleted 700 requestsCompleted 800 requestsCompleted 900 requestsCompleted 1000 requestsFinished 1000 requestsServer Software:        TornadoServer/4.3Server Hostname:        127.0.0.1Server Port:            8888Document Path:          /Document Length:        11 bytesConcurrency Level:      20Time taken for tests:   0.549 secondsComplete requests:      1000Failed requests:        0Total transferred:      204000 bytesHTML transferred:       11000 bytesRequests per second:    1821.49 [#/sec] (mean)Time per request:       10.980 [ms] (mean)Time per request:       0.549 [ms] (mean, across all concurrent requests)Transfer rate:          362.87 [Kbytes/sec] receivedConnection Times (ms)              min  mean[+/-sd] median   maxConnect:        0    0   0.1      0       1Processing:     1   11  10.2      8     157Waiting:        1   11  10.2      8     157Total:          2   11  10.2      8     158Percentage of the requests served within a certain time (ms)  50%      8  66%      9  75%     10  80%     11  90%     21  95%     24  98%     29  99%     30 100%    158 (longest request)



beego helloworld:

package mainimport (            "github.com/astaxie/beego"       )type MainController struct {        beego.Controller}func (this *MainController) Get() {        this.Ctx.WriteString("hello world")}func main() {        beego.Router("/", &MainController{})                beego.Run()}


ab测试:ab -n 1000 -c 20 http://127.0.0.1:8080/

Benchmarking 127.0.0.1 (be patient)Completed 100 requestsCompleted 200 requestsCompleted 300 requestsCompleted 400 requestsCompleted 500 requestsCompleted 600 requestsCompleted 700 requestsCompleted 800 requestsCompleted 900 requestsCompleted 1000 requestsFinished 1000 requestsServer Software:        beegoServer:1.6.1Server Hostname:        127.0.0.1Server Port:            8080Document Path:          /Document Length:        11 bytesConcurrency Level:      20Time taken for tests:   0.099 secondsComplete requests:      1000Failed requests:        0Total transferred:      155000 bytesHTML transferred:       11000 bytesRequests per second:    10093.06 [#/sec] (mean)Time per request:       1.982 [ms] (mean)Time per request:       0.099 [ms] (mean, across all concurrent requests)Transfer rate:          1527.76 [Kbytes/sec] receivedConnection Times (ms)              min  mean[+/-sd] median   maxConnect:        0    0   0.8      0      17Processing:     0    2   2.2      2      18Waiting:        0    1   0.7      2      18Total:          0    2   2.3      2      18WARNING: The median and mean for the waiting time are not within a normal deviation        These results are probably not that reliable.Percentage of the requests served within a certain time (ms)  50%      2  66%      2  75%      2  80%      2  90%      2  95%      2  98%     17  99%     18 100%     18 (longest request)

可以看出,beego借着go语言的优势,性能比tornado高很多,而且代码看着也很简洁




0 0
原创粉丝点击