pypy python jit测试基于twisted web服务
pypy python jit 测试 基于twisted web 服务
#coding:utf-8
'''''
the following line in setup.py (73):
下载twisted 源代码
打开setup.py
注释掉:
conditionalExtensions = getExtensions(),
=======================
../../pypy build
../../pypy install
./pypy 易做图web.py 8082
python 易做图web.py 8080
'''
import sys
from twisted.web import server, resource
from twisted.internet import reactor
class Simple(resource.Resource):
isLeaf = True
def render_GET(self, request):
return "<html>Hello, world!</html>"
site = server.Site(Simple())
reactor.listenTCP(int(sys.argv[1]), site)
reactor.run()
'''''
ab -n 10000 -c 10 http://127.0.0.1:8080/
cpython2.6
Requests per second: 1663.20 [#/sec] (mean)
Time per request: 6.013 [ms] (mean)
Time per request: 0.601 [ms] (mean, across all concurrent requests)
Requests per second: 1813.54 [#/sec] (mean)
Time per request: 5.514 [ms] (mean)
Time per request: 0.551 [ms] (mean, across all concurrent requests)
Requests per second: 1777.22 [#/sec] (mean)
Time per request: 5.627 [ms] (mean)
Time per request: 0.563 [ms] (mean, across all concurrent requests)
pypy 2.7 加速器运行效果
ab -n 10000 -c 10 http://127.0.0.1:8082/
Requests per second: 1056.80 [#/sec] (mean)
Time per request: 9.463 [ms] (mean)
Time per request: 0.946 [ms] (mean, across all concurrent requests)
Requests per second: 2420.05 [#/sec] (mean)
Time per request: 4.132 [ms] (mean)
Time per request: 0.413 [ms] (mean, across all concurrent requests)
Requests per second: 3130.71 [#/sec] (mean)
Time per request: 3.194 [ms] (mean)
Time per request: 0.319 [ms] (mean, across all concurrent requests)
稳定在:
Requests per second: 3041.53 [#/sec] (mean)
Time per request: 3.288 [ms] (mean)
Time per request: 0.329 [ms] (mean, across all concurrent requests)
ab -n 10000 -c 30 http://127.0.0.1:8082/
Requests per second: 4094.08 [#/sec] (mean)
Time per request: 7.328 [ms] (mean)
Time per request: 0.244 [ms] (mean, across all concurrent requests)
Requests per second: 4257.31 [#/sec] (mean)
Time per request: 7.047 [ms] (mean)
Time per request: 0.235 [ms] (mean, across all concurrent requests)
相比nginx 纯静态页面
ab -n 10000 -c 30 'http://127.0.0.1/t2.html'
Requests per second: 14106.12 [#/sec] (mean)
Time per request: 2.127 [ms] (mean)
Time per request: 0.071 [ms] (mean, across all concurrent requests)
对比echo "hello" 的php
ab -n 10000 -c 30 'http://127.0.0.1/t.php'
平均
Requests per second: 2887.00 [#/sec] (mean)
Time per request: 10.391 [ms] (mean)
Time per request: 0.346 [ms] (mean, across all concurrent requests)
Requests per second: 2799.78 [#/sec] (mean)
Time per request: 3.572 [ms] (mean)
Time per request: 0.357 [ms] (mean, across all concurrent requests)
python jit 的确效果不错
更多的效果对比参加:
http://speed.pypy.org
'''
本文出自 “沈冬明的技术博客” 博客
补充:Web开发 , Python ,