1

简单的问题...我只想在脚本中的各个位置打印出 CPU 时间,以查看执行所需的时间。

谢谢。

4

2 回答 2

1

日期 +%s.%N

应该(没有测试)在秒点纳秒上打印出 Unix 时间(当然不是那么准确)。

于 2012-10-08T18:33:03.420 回答
1

从字面上回答你的问题,

您需要查阅系统手册页ps以查看必须传递哪些选项才能查看 CPU 时间。它可能会显示在默认视图之一中。然后你需要运行一个并行进程来执行你的ps .... cmd., 在一个循环中,像sleep 1. 或者,您需要在后台运行您的 c-shell 启动进程,并在 cmd 末尾使用 '&' 字符,然后构造循环ps ... ; sleep 1;以查看状态。

但是.. 为什么不只是在脚本的每个部分之前和之后添加添加消息,即。

echo "P1 start : current time is `date`"
longrunningProcess1
echo "P1 end : current time is `date`"

echo "P2 start : current time is `date`"
longrunningProcess2
echo "P2 end : current time is `date`"

IHTH

于 2012-10-08T18:34:59.113 回答