打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
linux - top与ps间的区别

背景

  在linux系统中提供了2个查询系统负荷值的命令,一个是 ps -o THREAD 一个是 top ,这两个命令都能够查询当前进程的CPU使用率情况,但是所代表的含义确实不一样的,ps -o THREAD 偏向与整个进程周期所占的CPU使用率,而 top 更偏向于某个固定时间窗口的CPU使用率也就是说更倾向于查询实时CPU使用率。

具体

NOTES       This ps works by reading the virtual files in /proc.  This ps does not need to be setuid kmem or have any privileges to run.  Do not give this ps any special permissions.       This ps needs access to namelist data for proper WCHAN display.  For kernels prior to 2.6, the System.map file must be installed.       CPU usage is currently expressed as the percentage of time spent running during the entire lifetime of a process.  This is not ideal, and it does not conform to the       standards that ps otherwise conforms to.  CPU usage is unlikely to add up to exactly 100%.

  从第三行 CPU usage is currently expressed as the percentage of time spent running during the entire lifetime of a process 可知 CPU使用率表示为进程整个生命周期中 与 运行在CPU上所花费的时间 百分比

1. %CPU  --  CPU Usage           The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.           In a true SMP environment, if a process is multi-threaded and top is not operating in Threads mode, amounts greater than 100% may be reported.  You toggle Threads mode           with the `H' interactive command.

  根据 CPU Usage The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.知道CPU使用率是在一个单位时间窗口下该进程占用CPU时间与该单位时间的百分比值。

总结

  1. ps -o THREAD 命令更偏向于整个进程生命中占用CPU时间的比率
  2. top 命令更偏向于某个时间点占用CPU时间的比率
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
CPU飙高,系统性能问题如何排查?
常用性能监控指南
win7下如何使用wmi获取指定进程的CPU使用率?
嵌入式er:该知道如何计算CPU使用率(附代码)
Linux系统的CPU使用率和Load -- Linux -- IT技术大学习 -- 共学习 共进步!
聊聊 top 命令中的 CPU 使用率
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服