Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1561

Show
Ignore:
Timestamp:
12/22/06 23:03:36
Author:
fumanchu
Message:

Benchmark:

  1. Turned off default tools.
  2. New index page for testing in a browser.
  3. Added row of averages to thread report.
  4. Fixed bug in stop.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/test/benchmark.py

    r1332 r1561  
    4848 
    4949class Root: 
     50     
    5051    def index(self): 
     52        return """<html> 
     53<head> 
     54    <title>CherryPy Benchmark</title> 
     55</head> 
     56<body> 
     57    <ul> 
     58        <li><a href="hello">Hello, world! (14 byte dynamic)</a></li> 
     59        <li><a href="static/index.html">Static file (14 bytes static)</a></li> 
     60        <li><form action="sizer">Response of length: 
     61            <input type='text' name='size' value='10' /></form> 
     62        </li> 
     63    </ul> 
     64</body> 
     65</html>""" 
     66    index.exposed = True 
     67     
     68    def hello(self): 
    5169        return "Hello, world\r\n" 
    52     index.exposed = True 
     70    hello.exposed = True 
    5371     
    5472    def sizer(self, size): 
     
    6785    'server.max_request_header_size': 0, 
    6886    'server.max_request_body_size': 0, 
     87    # Cheat mode on ;) 
     88    'tools.log_tracebacks.on': False, 
     89    'tools.log_headers.on': False, 
     90    'tools.trailing_slash.on': False, 
    6991    }) 
    7092 
     
    175197                      ] 
    176198     
    177     def __init__(self, path=SCRIPT_NAME + "/", requests=1000, concurrency=10): 
     199    def __init__(self, path=SCRIPT_NAME + "/hello", requests=1000, concurrency=10): 
    178200        self.path = path 
    179201        self.requests = requests 
     
    205227 
    206228 
    207 def thread_report(path=SCRIPT_NAME + "/", concurrency=safe_threads): 
     229def thread_report(path=SCRIPT_NAME + "/hello", concurrency=safe_threads): 
    208230    sess = ABSession(path) 
    209231    attrs, names, patterns = zip(*sess.parse_patterns) 
     232    avg = dict.fromkeys(attrs, 0.0) 
     233     
    210234    rows = [('threads',) + names] 
    211235    for c in concurrency: 
    212236        sess.concurrency = c 
    213237        sess.run() 
    214         rows.append([c] + [getattr(sess, attr) for attr in attrs]) 
     238        row = [c] 
     239        for attr in attrs: 
     240            val = getattr(sess, attr) 
     241            avg[attr] += float(val) 
     242            row.append(val) 
     243        rows.append(row) 
     244     
     245    # Add a row of averages. 
     246    rows.append(["Average"] + [str(avg[attr] / len(concurrency)) for attr in attrs]) 
    215247    return rows 
    216248 
     
    324356        # can be tested from a standard web browser. 
    325357        def run(): 
     358            port = cherrypy.server.socket_port 
     359            print ("You may now open http://localhost:%s%s/" % 
     360                   (port, SCRIPT_NAME)) 
     361             
    326362            if "--null" in opts: 
    327363                print "Using null Request object" 
     
    335371                run_standard_benchmarks() 
    336372            finally: 
     373                cherrypy.engine.stop() 
    337374                cherrypy.server.stop() 
    338375     

Hosted by WebFaction

Log in as guest/cpguest to create tickets