Changeset 1561
- Timestamp:
- 12/22/06 23:03:36
- Files:
-
- trunk/cherrypy/test/benchmark.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/test/benchmark.py
r1332 r1561 48 48 49 49 class Root: 50 50 51 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): 51 69 return "Hello, world\r\n" 52 index.exposed = True70 hello.exposed = True 53 71 54 72 def sizer(self, size): … … 67 85 'server.max_request_header_size': 0, 68 86 '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, 69 91 }) 70 92 … … 175 197 ] 176 198 177 def __init__(self, path=SCRIPT_NAME + "/ ", requests=1000, concurrency=10):199 def __init__(self, path=SCRIPT_NAME + "/hello", requests=1000, concurrency=10): 178 200 self.path = path 179 201 self.requests = requests … … 205 227 206 228 207 def thread_report(path=SCRIPT_NAME + "/ ", concurrency=safe_threads):229 def thread_report(path=SCRIPT_NAME + "/hello", concurrency=safe_threads): 208 230 sess = ABSession(path) 209 231 attrs, names, patterns = zip(*sess.parse_patterns) 232 avg = dict.fromkeys(attrs, 0.0) 233 210 234 rows = [('threads',) + names] 211 235 for c in concurrency: 212 236 sess.concurrency = c 213 237 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]) 215 247 return rows 216 248 … … 324 356 # can be tested from a standard web browser. 325 357 def run(): 358 port = cherrypy.server.socket_port 359 print ("You may now open http://localhost:%s%s/" % 360 (port, SCRIPT_NAME)) 361 326 362 if "--null" in opts: 327 363 print "Using null Request object" … … 335 371 run_standard_benchmarks() 336 372 finally: 373 cherrypy.engine.stop() 337 374 cherrypy.server.stop() 338 375

