ps 和 top cpu 占用区别

ps和topcpu 占用区别:

但试了一会发现个不小的问题,把包含flash的网页关掉后,ps显示它的cpu占用率还是居高不下。奇怪了,难道它还在后台工作吗?我又用top看了下,更奇怪了,top显示flash占用的cpu分明是0。又等了一会,ps显示的还是好几十。

以前好像也发现过这样的问题,但以为是误差等问题也没细想,但今天看这显然和误差什么的没关系。

上网找了找,终于明白了。

看看man ps里的相关内容:

       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%.

再看看top的:

       k: %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 'Irix mode' is Off,  top  will  operate  in
          'Solaris  mode' where a task's cpu usage will be divided by the
          total number of CPUs.  You toggle 'Irix/Solaris' modes with the
          'I' interactive command.

就不难理解了。ps是从进程开始就开始算的,是平均的占用率;而top是从上次刷新开始算的,一般几秒钟一刷,可以认为是即时的。而桌面系统我们一般更关注即时的,所以top的cpu占用率才是我需要的。而且top默认cpu的占用率的和并不是100%,而是核数x100%,所以有时会有一个进程占用超过100%的情况。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值