Before optimizing a system, it is handy to know exactly which part is slow. IPython adds some specialized tools for this purpose, along with the tools that Python provides.
IPython provides a library called IPython.utils.timing
to time code execution. The library can be useful as relatively lightweight calls to include in code. Here is an example:
In [64]: import IPython In [65]: IPython.utils.timing.clocku() Out[65]: 218.533777 In [67]: IPython.utils.timing.clocku() Out[67]: 218.542776
This library distinguishes between two categories of time—user CPU time and system CPU time—as evidenced in the following functions:
Function |
Description |
---|---|
|
Returns the user CPU time in seconds since the start of the process |
|
Returns the system CPU time in seconds since the start of the process |
|
Returns the total (user + system) CPU time in seconds since the start of the process |
|
Returns a tuple of user/system times |
Another...