Created
September 26, 2014 19:56
-
-
Save anonymous/1c6565fba6572caada1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use this in the Django shell: | |
# ./manage.py shell | |
# >>> import profiling | |
# >>> profiling.profile_virtualevents() | |
from lib import dates | |
from schedules.virtual_events import VirtualEvent | |
import cProfile, pstats, StringIO | |
def profile_virtualevents(): | |
pr = cProfile.Profile() | |
pr.enable() | |
for i in range(20): | |
VirtualEvent.in_range(dates.utc(2014, 8, 1).date(), dates.utc(2014, 10, 1).date()) | |
pr.disable() | |
s = StringIO.StringIO() | |
ps = pstats.Stats(pr, stream=s).sort_stats('cumulative') | |
ps.print_stats() | |
print s.getvalue() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment