您的位置:首页 > 运维架构 > Shell

shell 命令 统计执行时间

2016-10-12 00:00 453 查看
start=`date +%s` && sh test.sh |sort|uniq -c && echo $[`date +%s` - $start]

shell 执行 sh test.sh |sort|uniq -c 命令并,统计执行命令花费的时间,单位为秒。。

可以使用 bash 的 time命令 如: time sh test.sh | sort |uniq -c

time 命令返回 real user sys时间

real:是该命令的总耗时,包括user和sys及io等待,时间片切换等待等等
user:是该命令在用户模式下的CPU耗时,也就是内核外的CPU耗时,不含IO等待这些时间
sys:是该命令在内核中的CPU耗时,不含IO,时间片切换耗时.
楼主需要的应该只是real这一项值
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: