get how much time python subprocess spends

后端 未结 3 1711
一整个雨季
一整个雨季 2021-02-19 01:04

I\'d like to time how long does the subprocess take. I tried to use

start = time.time()
subprocess.call(\'....\')
elapsed = (time.time() - start)
3条回答
  •  感情败类
    2021-02-19 01:32

    This is more accurate:

    from timeit import timeit
    print timeit(stmt = "subprocess.call('...')", setup = "import subprocess", number = 100)
    

提交回复
热议问题