sloth-cli
A library to speed the profile (cProfile) analyses of code performance on a per line basis. This library allow the user to call a python script file with arguments and analyse what lines of code are taking longer to process.
An example output of the sloth-cli:
Sat Jun 8 11:56:40 2019 profileOutput.profile
5400 function calls (5340 primitive calls) in 3.017 seconds
Ordered by: cumulative time
List reduced from 352 to 100 due to restriction <100>
ncalls tottime percall cumtime percall filename:lineno(function)
4/1 0.000 0.000 3.017 3.017 {built-in method builtins.exec}
1 0.000 0.000 3.017 3.017 tester.py:1(<module>)
1 0.000 0.000 3.014 3.014 tester.py:21(run)
3 3.012 1.004 3.012 1.004 {built-in method time.sleep}
Install
pip install sloth-cli
Decorator Usage
The sloth.profile allows you to gather the profile data by adding it as
a decorator. The decorator can be enabled or disabled whenever needed. It
can also be turned on by setting the environment variable SLOTH_PROFILE
to True (SLOTH_PROFILE='True') so you can set add it to your code and
leave it; then just turn it on when you need to validate the code performance.
To use the decorator do the following
import time
from sloth_cli import profile
def _loop_sleep():
"""Loops and sleeps"""
for i in range(3):
print(i)
time.sleep(1)
def _loop():
"""Loops 1000 times"""
ints = []
for i in range(1000):
ints.append(i)
@profile(enable=True, lines=50, builtins=False)
def run():
"""Run loops"""
_loop()
_loop()
_loop_sleep()
if __name__ == '__main__':
run()
10 function calls in 3.006 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 3.006 3.006 test_profiler.py:20(run)
1 3.005 3.005 3.005 3.005 test_profiler.py:6(_loop_sleep)
6 0.000 0.000 0.000 0.000 capture.py:413(write)
2 0.000 0.000 0.000 0.000 test_profiler.py:13(_loop)
CLI Usage
Using a tester.py cli script (argsparse):
To run tester.py with arguments:
sloth -f tester.py --cmd fake --fake-arg test
To get the tester.py help:
sloth -f tester.py -l 100 --cmd --help
Metadata
Release files for sloth-cli 1.1.1
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 | Actions |
|---|---|---|---|---|
| sloth-cli-1.1.1.tar.gz | 5.1 kB | Without provenance | Details for sloth-cli-1.1.1.tar.gz |
Release files / sloth-cli-1.1.1.tar.gz
| Download URL | sloth-cli-1.1.1.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c2b99bfcef3c89fb0dbe01ded08540cff0e6d59fb2ace38e4008bc202df29463
|
|
BLAKE2b-256 checksum How to use checksums |
8040d91e6d8716544f7fd4b27293216958281102e369b3444893063018e4d787
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.4.2 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.2
|
Security for sloth-cli 1.1.1
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.