[BangPypers] log and figure out what bits are slow and optimize them.
anandology at gmail.com
Sun Feb 12 15:39:08 CET 2012
2012/2/12 Saju M <sajuptpm at gmail.com>:
> 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
I found this technique very useful to optimize webapps. Here is an example:
web.py has a nice profile middleware, it shouldn't be too hard to reuse it.
More information about the BangPypers