Login

Tag "profiling"

Snippet List

Fetching list of SQL queries executed so far for all requests

These snippets together give you the ability to view all Django SQL queries executed across all incoming requests by visiting a particular URL (`/profiling` in the example). This is useful when developing with the Django test server. This is useful if most of the incoming requests are AJAX requests, because in such cases the debug toolbar will not be able to show which queries got executed. The `SqlProfilingMiddleware` class is the key one. At the end of every incoming request it appends the executed SQL queries to a static class member list. Any information request profiling information can be added in this way. The snippet does not add any security around viewing such information. This was done just to keep the code simple. But when implementing this you will definitely want to restrict access to this URL to only people allowed to view such information.

  • sql
  • debugging
  • profiling
Read More

Timing Django Requests

Adds an 'X-Django-Request-Time' HTTP response header that times how long django spent processing the request.

  • middleware
  • http
  • headers
  • profiling
Read More

Create breakpoints to time code at

Include in your code like this: t=Timer() Then use it like this: t.tick('Some optional description') It will output the time spent between the tick and the previous tick (or inception) and the total time spent since it began tracking time. Can be placed multiple times in a long segment of code. Can be used to break out the amount of time being spent on various parts of your code so you can focus on optimizing those sections.

  • time
  • high-performance
  • profiling
  • timer
  • optimize
Read More

4 snippets posted so far.