Задать вопрос

Тел: +7 965 3737 888

457

Просмотров

10

Ответов

Profiling Middlware

Displays hotshot profiling for any view. http://yoursite.com/yourview/?prof

Add the "prof" key to query string by appending ?prof (or &prof=) and you'll see the profiling results in your browser. It's set up to only be available in django's debug mode, but you really shouldn't add this middleware to any production configuration.

Вопрос полезен? Да0/Нет0
file_4906.py(1.6Кб)
None

Ответы (10):

Ответfisher:03.02.2008
Ответ полезен? Да0/Нет0

Works ok on Mac OS X (Python 2.4.4)

Ответdivkis01:23.09.2011
Ответ полезен? Да0/Нет0

I get the following error: Not sure what is causing this. Given hotshot is no more maintained, I see no reference to similar issues found by others. I tried using cProfile but the syntax for cProfile somehow doesn't allow me to work with callbacks passed to the process_view.

profile_middleware.py", line 61, in process_view stats = hotshot.stats.load(filename) File "/usr/lib/python2.6/hotshot/stats.py", line 15, in load return StatsLoader(filename).load() File "/usr/lib/python2.6/hotshot/stats.py", line 54, in load assert not self._stack AssertionError

Ответcerinin:19.09.2011
Ответ полезен? Да0/Нет0

Error 330 (net::ERR_CONTENT_DECODING_FAILED): Unknown error.

Ответcerinin:16.09.2011
Ответ полезен? Да0/Нет0

This doesn't work for me on Ubuntu. It causes the request to hang indefinitely...

Ответbvemu:05.10.2009
Ответ полезен? Да0/Нет0

Exactly what I was looking for

Thanks a lot !!

Ответtobu:22.08.2008
Ответ полезен? Да0/Нет0

With a recent django (1.0b1), you get:

AttributeError: 'WSGIRequest' object has no attribute 'has_key'

This is fixed by replacing request.has_key with request.GET.has_key .

Ответtobu:23.11.2007
Ответ полезен? Да0/Нет0

The imports went missing, here they are:

import sys
import tempfile
import hotshot
import hotshot.stats
from django.conf import settings
from cStringIO import StringIO

Ответpootow:10.06.2007
Ответ полезен? Да0/Нет0

Very helpful, thanks!

Ответudfalkso:02.05.2007
Ответ полезен? Да0/Нет0

Thanks nikto. I've only tested this on linux.

Ответnikto:25.04.2007
Ответ полезен? Да0/Нет0

FWIW for me this didn't work on windows. I needed to switch to mkstemp since NamedTemporaryFile doesn't seem to like you re-opening the file on windows. After making that change and adding os.unlink its all good now.