the5fire

关注Python、Django、Vim、Linux、Web开发、团队管理和互联网--Life is short, we need Python.


测试PyPy运行Django项目对比Python

作者:the5fire | 标签:       | 发布:2013-05-30 6:48 a.m. | 阅读量: 11218, 10781

继续昨天的文章,终于用pypy跑起了Django和MySQL,今天就把blog用pypy在本地跑一下试试。然后顺便用ab测一下,看看效果。

先介绍下我的环境:

  • ubuntu13.04 64位
  • i5-2410的cpu
  • 4G DDR3内存

软件环境就是,用gunicorn通过wsgi的方式启动Django1.5.1.

只是测试了并发100, 10000次访问的情况。得到的结果是:由pypy运行的gunicorn 平均每秒处理13.32个请求;通过python2.7.3执行的gunicorn,平均每秒处理11.09 个请求。

这个差别并不大,不过关于内存占用的差别倒是挺出乎意料的,基于pypy运行的gunicorn占了300M多的内存,而后者,我之前也说过,30M左右。这个差异还是挺大的。

有兴趣的可以自己在本地跑一个Django项目,然后测试对比一下。

最后是完整的记录:

  • 先是Python2.7.3:
Server Software:        gunicorn/0.17.4
Server Hostname:        127.0.0.1
Server Port:            8888

Document Path:          /
Document Length:        36482 bytes

Concurrency Level:      100
Time taken for tests:   901.496 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      366790000 bytes
HTML transferred:       364820000 bytes
Requests per second:    11.09 [#/sec] (mean)
Time per request:       9014.955 [ms] (mean)
Time per request:       90.150 [ms] (mean, across all concurrent requests)
Transfer rate:          397.33 [Kbytes/sec] received

Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        0    0   0.7      0      10
Processing:   686 8981 2641.9   7934   19722
Waiting:      686 8980 2641.8   7933   19721
Total:        696 8981 2641.8   7935   19722

Percentage of the requests served within a certain time (ms)
50%   7935
66%   9416
75%  10341
80%  10836
90%  12515
95%  14492
98%  17245
99%  18081
100%  19722 (longest request)
  • 然后是Pypy2.0.2:
Server Software:        gunicorn/0.17.4
Server Hostname:        127.0.0.1
Server Port:            8000

Document Path:          /
Document Length:        36482 bytes

Concurrency Level:      100
Time taken for tests:   750.585 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      366790000 bytes
HTML transferred:       364820000 bytes
Requests per second:    13.32 [#/sec] (mean)
Time per request:       7505.848 [ms] (mean)
Time per request:       75.058 [ms] (mean, across all concurrent requests)
Transfer rate:          477.22 [Kbytes/sec] received

Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        0    0   0.7      0      10
Processing:   444 7466 2179.8   6554   17179
Waiting:      443 7466 2179.8   6554   17178
Total:        454 7466 2179.7   6554   17179

Percentage of the requests served within a certain time (ms)
50%   6554
66%   7239
75%   8438
80%   9181
90%  10498
95%  12012
98%  14026
99%  15469
100%  17179 (longest request)

update: pypy的成员alex写了片关于pypy测试的文章,有兴趣的可以了解下,英文的: http://alexgaynor.net/2013/jul/15/your-tests-are-not-benchmark/

- from the5fire.com
----EOF-----

微信公众号:Python程序员杂谈


其他分类: