Skip to content

Instantly share code, notes, and snippets.

@mattharley
Created August 18, 2014 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattharley/a6578b42fcc3b6ad5a84 to your computer and use it in GitHub Desktop.
Save mattharley/a6578b42fcc3b6ad5a84 to your computer and use it in GitHub Desktop.
Profiling Django

https://github.com/frankwiles/django-app-metrics Use this guy

https://code.djangoproject.com/wiki/ProfilingDjango Timing Python calls: http://docs.python.org/library/hotshot.html

prof = hotshot.Profile(final_log_file)
try:
    ret = prof.runcall(f, *args, **kwargs)
finally:
    prof.close()
return ret

https://code.google.com/p/django-profiling/source/browse/trunk/profiling/middleware.py Can get the CPU time and Memory usage

from guppy import hpy
h = hpy()
mem_profile = h.heap()

https://github.com/garethr/django-timelog/blob/master/src/timelog/middleware.py

d = {
    'method': request.method,
    'time': time.time() - request._start,
    'code': response.status_code,
    'url': smart_str(request.path_info),
    'sql': len(connection.queries),
    'sqltime': sqltime,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment