[BangPypers] log and figure out what bits are slow and optimize them.
Anand Chitipothu
anandology at gmail.com
Sun Feb 12 15:39:08 CET 2012
2012/2/12 Saju M <sajuptpm at gmail.com>:
> Hi,
> I wrote a decorator using cProfile.
> Issue is log-file getting messed up with logs of unwanted method
> calls(library calls).
> I tried with prof.getstats() and prof.print_stats(), prof.getstats() force
> to code extra loops to get infos.
> I am also planning to enable/disable this logging using DEBUG flag.
>
> Have any suggestions to improve this code ??? or any other-way ??
Since you are doing this in a webapp, you should be able to write a
WSGI middleware that enables the profiler if profile=true is passed as
query parameter.
I found this technique very useful to optimize webapps. Here is an example:
http://openlibrary.org/books/OL1M/Kabit%C4%81.?_profile=true
web.py has a nice profile middleware, it shouldn't be too hard to reuse it.
https://github.com/webpy/webpy/blob/master/web/http.py#L140
https://github.com/webpy/webpy/blob/master/web/utils.py#L1070
Anand
More information about the BangPypers
mailing list