Monday, February 26, 2018

Find the speed limiting part of your Python code

Say you have a Python code, 'simple.py' like this:
import time
def func_A():
    time.sleep(1)
def func_B():
    time.sleep(10)
    
if __name__=='__mian__':
    func_A()
    func_B()
and you want to figure out which part takes the most time to finish. What you can do is:
python -m cProfile simple.py
However, the output is kinda too complicated to understand.
A better way is to use 'cprofilev', which you can install from here.
python -m cProfilev simple.py
Output would look like:
[cProfileV]: cProfile output available at http://127.0.0.1:4000
Just go to http://127.0.0.1:4000 and all the information are right there waiting for you.
## https://github.com/ymichael/cprofilev

No comments:

Post a Comment

Any comments?

my-alpine and docker-compose.yml

 ``` version: '1' services:     man:       build: .       image: my-alpine:latest   ```  Dockerfile: ``` FROM alpine:latest ENV PYTH...