Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Profiling python fabric commands in each task

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.

like image 652
Shiplu Mokaddim Avatar asked Jun 22 '26 23:06

Shiplu Mokaddim


1 Answers

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.

like image 104
M.A.K. Simanto Avatar answered Jun 24 '26 13:06

M.A.K. Simanto



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!