- #include<iostream>
- usingnamespace
- boolfloatsize_tintint
- boolfalse
- char
- FILE
- "r"
- if
- returnfalse
- char
- float
- int
- float
- int
- int
- if
- if
- if
- true
- else
- while
- if
- true
- break
- if
- else
- else
- return
- intintchar
- float
- size_t
- int
- int
- if
- else
- if
- while
- if
- "%%CPU:%.1f\tMEM:%dMB\n"
- else
- break
- return
编译:g++ GetInfo.cpp -o GetInfo -g
测试命令:
pid
显示pid进程cpu及内存信息
pid tid
显示pid进程的内存占用和其中tid线程的cpu占用信息