- 论坛徽章:
- 0
|
这是用webpy 写的helloworld ,用siege做压力测试
import web
urls = ("/.*","hello")
app = web.application(urls, globals())
class hello():
def GET(self):
return "Hello World!!"
if __name__ == "__main__":
app.run()
siege -c 200 -t 10s http://127.0.0.1:8080/
#python index2.py
Lifting the server siege... done.
Transactions: 3388 hits
Availability: 100.00 %
Elapsed time: 9.51 secs
Data transferred: 0.04 MB
Response time: 0.07 secs
Transaction rate: 356.26 trans/sec
Throughput: 0.00 MB/sec
Concurrency: 25.07
Successful transactions: 3388
Failed transactions: 0
Longest transaction: 2.74
Shortest transaction: 0.00
#pypy index2.py
Lifting the server siege... done.
Transactions: 1170 hits
Availability: 99.41 %
Elapsed time: 9.24 secs
Data transferred: 0.05 MB
Response time: 0.63 secs
Transaction rate: 126.62 trans/sec
Throughput: 0.01 MB/sec
Concurrency: 80.19
Successful transactions: 1170
Failed transactions: 7
Longest transaction: 7.35
Shortest transaction: 0.00
siege -c 200 -t 20s http://127.0.0.1:8080/
#python index2.py
Lifting the server siege... done.
Transactions: 6222 hits
Availability: 99.27 %
Elapsed time: 19.12 secs
Data transferred: 0.08 MB
Response time: 0.07 secs
Transaction rate: 325.42 trans/sec
Throughput: 0.00 MB/sec
Concurrency: 23.18
Successful transactions: 6222
Failed transactions: 46
Longest transaction: 5.45
Shortest transaction: 0.00
#pypy index2.py
Lifting the server siege... done.
Transactions: 2426 hits
Availability: 98.66 %
Elapsed time: 19.62 secs
Data transferred: 0.08 MB
Response time: 0.89 secs
Transaction rate: 123.65 trans/sec
Throughput: 0.00 MB/sec
Concurrency: 109.63
Successful transactions: 2426
Failed transactions: 33
Longest transaction: 17.71
Shortest transaction: 0.00
siege -c 400 -t 10s http://127.0.0.1:8080/
#python index2.py
Lifting the server siege... done.
Transactions: 2935 hits
Availability: 100.00 %
Elapsed time: 9.13 secs
Data transferred: 0.04 MB
Response time: 0.59 secs
Transaction rate: 321.47 trans/sec
Throughput: 0.00 MB/sec
Concurrency: 188.88
Successful transactions: 2935
Failed transactions: 0
Longest transaction: 8.37
Shortest transaction: 0.00
#pypy index2.py
Lifting the server siege... done.
Transactions: 1246 hits
Availability: 96.07 %
Elapsed time: 9.51 secs
Data transferred: 0.02 MB
Response time: 1.74 secs
Transaction rate: 131.02 trans/sec
Throughput: 0.00 MB/sec
Concurrency: 227.38
Successful transactions: 1246
Failed transactions: 51
Longest transaction: 8.67
Shortest transaction: 0.01
结果现实pypy 速度至多是python(我的是2.7.3的) 一半,甚至一般也不到
而我在另一个测试中pypy 差不多是python 的50倍了
另一个测试,代码:
# filename : t.py
import os, sys, string
def hello(n=1):
a = 0
print 'Hello World!!'
while(n):
a += 1
n -= 1
print a
if __name__ == '__main__':
try:
hello(string.atoi(sys.argv[1]))
except IndexError:
hello()
# time python t.py 99999999
Hello World!!
99999999
real 0m10.707s
user 0m10.681s
sys 0m0.008s
# time pypy t.py 99999999
Hello World!!
99999999
real 0m0.225s
user 0m0.212s
sys 0m0.012s
在webpy 里慢,原因在哪里?? |
|