rgv*_*ley 7 php bash benchmarking
我想对PHP脚本进行基准测试,但这同样适用于可以从命令行运行的任何内容.
使用bash有一种简单的方法来对脚本进行基准测试,即多次运行命令并计算需要多长时间?
Xiè*_*léi 15
在命令行中,您可以:
$ time php foobar.php
Run Code Online (Sandbox Code Playgroud)
这time是一个内置的bash.
对于多次运行:
$ time for a in {1..10}; do php foobar.php; done
real 0m13.042s
user 0m0.021s
sys 0m0.044s
Run Code Online (Sandbox Code Playgroud)
但是,您需要手动计算平均时间.