频道栏目
首页 > 程序开发 > Web开发 > Python > 正文
pypy python jit测试基于twisted web服务
2011-08-06 15:04:21           
收藏   我要投稿

 

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 simpleweb.py 8082

python simpleweb.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 https://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 https://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 https://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 'https://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 'https://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 的确效果不错

更多的效果对比参加:

https://speed.pypy.org

 

'''

 

本文出自 “沈冬明的技术博客” 博客

点击复制链接 与好友分享!回本站首页
相关TAG标签
上一篇:Python入門語法和類型
下一篇:浅谈Python web框架
相关文章
图文推荐
文章
推荐
点击排行

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站