A package that allows timing of each individual line of code in a function, and produces a colour-coded output
Project description
Deep time-it
Deep time-it is an open source module that was intended to be an extension of the timeit library, that not only times a function, but can also time each individual line and chunk of code within it, and produce a visual break-down of the slower and faster parts to aid with debugging and refactoring.
Important
This was not intended to compete with the timeit library, as both modules have their advantages. For example, this module only times functions once, whereas timeit does it several times, which gives a better average of how long the code takes to execute.
Also, be careful if your function that you are timing has side effects. If it does, then as sometimes the function may be run twice, the side effect might occur twice. To disable double running, set the reattempt
flag to false.
Installation
To install the Deep time-it library, use pip install deep_timeit
. The documentation can be found at TODO. We support Python versions 3.6 to 3.10.
Usage
Run deep_timeit.deepTimeit(function)
, and replace function
with a reference to the function you want to time. It includes the additional flags args
and kwargs
, which you can set to a list and dictionary respectively that includes additional arguments and keyword arguments to include when timing the function. The other flags are reattempt
, which if set to True, which it is by default, will check if any lines are run more than a large threshhold e.g. 10,000 and in which case will reattempt timing the function without timing those particular lines. This is a feature because if it times a line a large number of times, the timing itself will start to contribute to the time taken. The show
keyword, which is set to True by default, defines whether or not to display the time breakdown, or if set to False, to simply return an Info
object, which can be displayed by running infoob.show()
. Finally, the mintime
keyword, if it is not set to None, which it is by default, will set every colour to green if the code executes faster than the mintime
flag.
Release notes
TODO
Similar libraries
- timeit
- line_profiler
- pprofile
TODO's
Make code work with functions that have:
- globals
- empty lines
- comments
- multi-line strings
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for deep_timeit-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cb7555632b78b1685ca49daf9d545d26661287407f2c97c656371826bcde0cf |
|
MD5 | 5bdacfe570e22608be8fea4fe92a1285 |
|
BLAKE2b-256 | 1840af2da897e9de3a5b692572d1d7f590dcbaf1b3f9e39f729985cdcbc90661 |