flask-profiler
flask-profiler copied to clipboard
incorporating cProfile output into the page
I really like the webpage output of the endpoint statistics. It would be great to include the output from cProfile for each out as well, perhaps even in a visual way. I can see the option of clicking on one of the routes on the main page, and instead of simply displaying the detailed header info, it takes you to a new page that has that header info plus the detailed output from cProfile. How feasible is this?
Flask has a built-in profiler that you can run, which I'm currently using. It would be great to combine these two somehow. http://werkzeug.pocoo.org/docs/0.11/contrib/profiler/
The relevant code lines are
from werkzeug.contrib.profiler import ProfilerMiddleware, MergeStream
if logdirs: logpath = os.path.join(logdirs, 'profile.log') file = open(logpath, 'w') stream = MergeStream(sys.stdout, file) else: stream = None
app.config['PROFILE'] = True app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30], stream=stream) app.run(debug=True, port=args.port)
Indeed, in the past, I thought the same. but I did not have enough time. maybe, somebody who is willing to contribute or I can work on this.