Skip to content

Instantly share code, notes, and snippets.

Created September 26, 2014 19:56
Show Gist options
  • Save anonymous/1c6565fba6572caada1a to your computer and use it in GitHub Desktop.
Save anonymous/1c6565fba6572caada1a to your computer and use it in GitHub Desktop.
# 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