Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[efe1d1]: examples / web_framework / profile_server.py Maximize Restore History

Download this file

profile_server.py    17 lines (13 with data), 442 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# profile_server.py
import cProfile
import simple_server
def run(port=8080, logging=False, trace_sql=False, db_engine='sqlite3'):
cProfile.runctx(
'simple_server.run(port=%d, logging=%s, trace_sql=%s, db_engine=%r)'
% (port, logging, trace_sql, db_engine),
globals(), locals(), 'profile.out')
def stats():
import pstats
p = pstats.Stats('profile.out')
p.sort_stats('time')
p.print_stats(20)