linux中top和ps的内存区别,linux - top与ps间的区别
背景
在linux系統(tǒng)中提供了2個(gè)查詢系統(tǒng)負(fù)荷值的命令,一個(gè)是 ps -o THREAD 一個(gè)是 top ,這兩個(gè)命令都能夠查詢當(dāng)前進(jìn)程的CPU使用率情況,但是所代表的含義確實(shí)不一樣的,ps -o THREAD 偏向與整個(gè)進(jìn)程周期所占的CPU使用率,而 top 更偏向于某個(gè)固定時(shí)間窗口的CPU使用率也就是說更傾向于查詢實(shí)時(shí)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使用率表示為進(jìn)程整個(gè)生命周期中 與 運(yùn)行在CPU上所花費(fèi)的時(shí)間 百分比
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.
根據(jù) 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使用率是在一個(gè)單位時(shí)間窗口下該進(jìn)程占用CPU時(shí)間與該單位時(shí)間的百分比值。
總結(jié)
ps -o THREAD 命令更偏向于整個(gè)進(jìn)程生命中占用CPU時(shí)間的比率。
top 命令更偏向于某個(gè)時(shí)間點(diǎn)占用CPU時(shí)間的比率。
總結(jié)
以上是生活随笔為你收集整理的linux中top和ps的内存区别,linux - top与ps间的区别的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c web mysql数据库_C连接My
- 下一篇: 【c语言数据结构】二叉树