How can I profile python fabric? I need to know which command in a task takes most time.
Say I have a fabfile.py which has 1 task. To perform this it passess 10 commands though ssh. When I run, it should output the time each command took and sort it.
I searched the fabric documentation. Didn't find any way to write plugin/hook etc.
You can use time
for task level duration:
$time fab command
for command level duration time can be injected in task definition:
def status():
""" Is our app live? """
sudo("time forever list")
Apart from that the trivial time duration can be decorated
from timeit import default_timer as timer
start = timer()
# ...run('run a command')
end = timer()
print(end - start)
Theres hardly any support from fabric wiki and project regarding this, but will be a exciting add-on to develop.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With