【发布时间】:2017-09-11 00:18:18
【问题描述】:
我有 bash shell 脚本,它在内部调用 python 脚本。我想知道执行 python 需要多长时间。我不允许在 python 脚本中进行更改。 任何线索都会有所帮助,提前致谢。
【问题讨论】:
我有 bash shell 脚本,它在内部调用 python 脚本。我想知道执行 python 需要多长时间。我不允许在 python 脚本中进行更改。 任何线索都会有所帮助,提前致谢。
【问题讨论】:
可以使用time命令获取python脚本的运行时间。
]$ cat time_test.bash
#!/bin/bash
# You can use: time python script.py
time python -c 'import os;os.getenv("HOME")'
输出会是这样的
]$ ./time_test.bash
real 0m0.010s
user 0m0.005s
sys 0m0.005s
【讨论】:
使用/usr/bin/time script 调用python 脚本。这允许您跟踪脚本的 CPU 和挂钟时间。
【讨论】: