【问题标题】:Linux more precise cpu usageLinux 更精确的 cpu 使用率
【发布时间】:2015-04-30 10:50:49
【问题描述】:

我可以用ps命令得到cpu使用百分比

ps -ax -o pid,rss,pcpu,command

但有些进程会打印 0.0。我知道原因是因为值太小。有什么方法(例如 ps 选项)可以更精确地打印这些值,例如 0.002?

【问题讨论】:

标签: linux cpu-usage ps


【解决方案1】:

ps 或 top 无法为您提供 cpu 使用率的准确结果。 也许您可以尝试使用 OProfile 来准确地为您提供进程消耗的 CPU 使用率。 以下链接包含有关 OProfile 的基本操作指南: http://lbrandy.com/blog/2008/11/oprofile-profiling-in-linux-for-fun-and-profit/

【讨论】:

  • 其实/proc/pid/stat提供的CPU使用精度为10ms的cpu时间(取决于USER_HZ)。
猜你喜欢
  • 1970-01-01
  • 2011-07-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多