Django Debug Toolbar: understanding the time panel

Question:

I’m running the Django Debug Toolbar to profile my site and try to figure out why certain views are taking so long. It’s been immensely valuable with regards to seeing what queries I’m running and how much they’re costing me, but I can’t understand how to read the time panel.

I’ve looked around everywhere for some documentation on this but can’t seem to find anything. I should mention that I’m a self-taught, relatively new programmer, so these may be terms that are assumed to be familiar to the experienced programmer.

Here is the output:

Resource         Value
User CPU time    3760.000 msec
System CPU time  340.000 msec
Total CPU time   4100.000 msec
Elapsed time     4625.453 msec
Context switches 248 voluntary, 467 involuntary

Can anyone help me figure out how to read this, and what each of the values represents?

Thanks.

Asked By: rolling stone

||

Answers:

User CPU time: The time your server-side code ran while processing the request

System CPU time: The time operating system code called by your server-side code ran while processing the request

Total CPU time: total time to fully respond once request was received (user+system)

Elapsed time: Time since request was made.

Context switches: This has to do with threads. Voluntary switches are times when a thread slept of its own accord (usually to wait for some of processing to occur that it needs to continue), whereas involuntary switches are times when the system forced a thread to sleep in order to run some other thread (usually part of asynchronous processes). It’s actually pretty low-level system stuff, that I couldn’t do justice to here. If you’re interested in learning more, just search for “context switching”.

Answered By: Chris Pratt