问题描述
是否有运行时,打印了为每个包的时间任何方便的方式pip install -r requirements.txt
?
我想是这样pip install -r requirement.txt --print-times
并且,而不是仅仅印刷包装和版本的名称,我想输出看起来是这样的:
Collecting shellescape==3.8.1
Using cached shellescape-3.8.1-py2.py3-none-any.whl (3.1 kB)
took 2.4 seconds
Collecting lxml==4.5.2
Using cached lxml-4.5.2-cp38-cp38-manylinux1_x86_64.whl (5.4 MB)
Collecting gevent==20.9.0
Using cached gevent-20.9.0-cp38-cp38-manylinux2010_x86_64.whl (6.1
took 4.4 seconds
等等...
我没有找到下--verbose此数据。
谢谢!
编辑:
我所知,就像写一个bash / Python脚本的选择,但我在寻找一个简单的标志或单行命令。
解决方法
我给你一个建议,你可以使用python程序:
- 打开你的requirement.txt (
f = open('requirement.txt','r')
) - 读取文件 (
doc = f.readlines()
) - 在 for 循环中取每一行
- 初始化计时器 (
t0 = time.time()
) - 在 python 中使用 pip 包运行 pip install
- 显示花费的时间 (
time.time() - t0
) - 使用别名代替运行此脚本而不是 pip install
用这个内容创建一个 bash 脚本
while IFS= read -r line; do
start=`date +%s`
pip install $line
end=`date +%s`
runtime=$((end-start))
echo "took $runtime seconds"
done < requirements.txt