Python简单的http获取服务器测试

时间:2016-04-04 13:36:38

标签: python httpserver

我在这段代码上做错了什么?

#!/usr/bin/python
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer

PORT_NUMBER = 3000

class serverHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.send_header('Content-type','text/html')
        self.end_headers()
        self.wfile.write('yo')
        return

try:
    #Create a web server and define the handler to manage the
    #incoming request
    server = HTTPServer(('', PORT_NUMBER), serverHandler)
    print 'Started httpserver on port ' , PORT_NUMBER

    #Wait forever for incoming htto requests
    server.serve_forever()

except KeyboardInterrupt:
    print '^C received, shutting down the web server'
    server.socket.close()

当我测试动臂性能时,性能结果非常糟糕......

当我从服务器解雇Boom时:

boom -n 100000 -c 10000 http://localhost:3000

我收到了这个结果:

Summary:
  Total:    25.5676 secs
  Slowest:  4.2101 secs
  Fastest:  0.9872 secs
  Average:  1.7560 secs
  Requests/sec: 380.0513

Status code distribution:
  [200] 9717 responses

Response time histogram:
  0.987 [1] |
  1.309 [1792]  |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  1.632 [2670]  |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  1.954 [1681]  |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  2.276 [2616]  |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  2.599 [446]   |∎∎∎∎∎∎
  2.921 [283]   |∎∎∎∎
  3.243 [171]   |∎∎
  3.565 [31]    |
  3.888 [1] |
  4.210 [25]    |

Latency distribution:
  10% in 1.0313 secs
  25% in 1.5239 secs
  50% in 1.7353 secs
  75% in 2.0630 secs
  90% in 2.2717 secs
  95% in 2.6155 secs
  99% in 3.1570 secs

与其他语言相同的测试有更好的性能,请参阅此处的来源:https://github.com/ericmdantas/bm

0 个答案:

没有答案