time_profiler
This is a Python module for profiling a function's time usage. It's quite useful for determining how long a function will take to execute.
Installation
Install via pip:
pip install time_profiler
Usage
First decorate the function you would like to profile with @timer() and then run that file containing function.
In the following example, we create a simple function called sample_func that allocates lists a, b and then deletes b:
from time_profiler import timer
@timer()
def sample_func():
a = [1] * (10 ** 6)
b = [2] * (2 * 10 ** 7)
del b
return a
if __name__ == '__main__':
sample_func()
Then execute the code normally. For example, if the file name was example.py, this would result in:
python example.py
Output will be displayed in the terminal as follow:
11-24-2021 10:07:05 AM - timer - INFO - sample_func function ran in 0.10 secs
Parameters
This decorator(@timer()) takes two optional paramaters.
-
file_log: By default is set to false, which means that log file is not created but when set to true there should be a log file named timer.log. Breifly this argument is of boelen type.
-
exp_time: Here you can try to estimate the time to be used. When estimated time is less than actual used time, you get warning log instead of info.
Development
Latest sources are available from github:
Author
Carlos Harerimana
License
MIT
Metadata
Release files for time-profiler 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| time_profiler-0.0.2.tar.gz | 3.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| time_profiler-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.5 kB
Release files / time_profiler-0.0.2.tar.gz
| Download URL | time_profiler-0.0.2.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61431f006461e4a1f6bad10ddc280d829b007931cb87f2d313371518de2838e1
|
|
BLAKE2b-256 checksum How to use checksums |
c5b53a0d12866126cbfd70bdf39057aa16c4682e51e608a4cbad54bd7e14e53b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.8.8 Linux/5.11.0-40-generic
|
Release files / time_profiler-0.0.2-py3-none-any.whl
| Download URL | time_profiler-0.0.2-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19c805cb8283c985f119eba790b72048d915f369d542bf1712971bb4534e0e62
|
|
BLAKE2b-256 checksum How to use checksums |
8649306b14e9a998c31dcdb910da0dd0e0757940926d76e10ec0718ab959f084
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.8.8 Linux/5.11.0-40-generic
|
Security for time-profiler 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.