flask-profiler icon indicating copy to clipboard operation
flask-profiler copied to clipboard

incorporating cProfile output into the page

Open havok2063 opened this issue 8 years ago • 1 comments

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)

havok2063 avatar Jun 09 '16 18:06 havok2063

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.

muatik avatar Jun 11 '16 15:06 muatik