从C程序度量页面错误 [英] Measure page faults from a c program
问题描述
我比较了几个系统调用,我从/内存读/写。是否有 C
?
I am comparing a few system calls where I read/write from/to memory. Is there any API defined to measure page faults (pages in/out) in C
?
我发现这个库<一个href=\"http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.prftools/doc/prftools/idprftools_perfstat_glob_memory.htm\">libperfstat.a但它是 AIX
,我找不到for linux的东西。
I found this library libperfstat.a but it is for AIX
, I couldn't find anything for linux.
编辑:
我知道时间
&安培; 穿孔 - STAT
在Linux命令,只是探索是否有可用的东西给我的 C
程序中使用。
I am aware of time
& perf-stat
commands in linux, just exploring if there is anything available for me to use inside the C
program.
推荐答案
有 的getrusage
功能(SVR4,4.3BSD POSIX.1-2001;但并不是所有领域都在标准中定义)。在linux下有几个破碎领域的,但是的 男人的getrusage
列出了几个有趣的领域:
There is getrusage
function (SVr4, 4.3BSD. POSIX.1-2001; but not all fields are defined in standard). In linux there are several broken fields, but man getrusage
lists several interesting fields:
long ru_minflt; /* page reclaims (soft page faults) */
long ru_majflt; /* page faults (hard page faults) */
long ru_inblock; /* block input operations */
long ru_oublock; /* block output operations */
的 rusage
另据报道在 wait4
(仅在外部程序使用)。这一个是用于的/ usr / bin / time会
程序(它打印次要/主要页缺失计数)。
The rusage
is also reported in wait4
(only usable in external program). This one is used by /usr/bin/time
program (it prints minor/major pagefault counts).
这篇关于从C程序度量页面错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!