Mittwoch, 28. Februar 2007

Profiling Django: hotshot

Today I've discovered an article about profiling Django with hotshot. After some minutes of googling 'hotspot' I recognized my fault and found the right python doc.
As I didn't want to setup my apache just for a little profiling session, I did the following:
to I've added
import hotshot
PROF = hotshot.Profile("")
every view-method that should be profiled got:
from settings import PROF

and finally this came to my 'viewstat'-view:
import hotshot.stats
stats = hotshot.stats.load("")
stats.sort_stats('time', 'calls')

And that's how I've become happy today. Wish me good luck for my cold.
- baum

It's fair to say that this probably won't run in a production-setup because of multithreading.

Keine Kommentare: