2012/2/12 Saju M <sajup...@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
_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to