What profiler should I use to measure _real_ time (including waiting for syscalls) spend in this function, not _CPU_ one

こ雲淡風輕ζ 提交于 2019-12-20 01:46:59

问题


The application does not calculate things, but does i/o, read files, uses network. I want profiler to show it.

I expect something like something like in callgrind that calls clock_gettime each proble.

Or like oprofile that interrupts my application (while it is sleeping or waiting for socket/file/whatever) to see what is it doing.

I want things like "read", "connect", "nanosleep", "send" and especially "fsync" (And all their callers) to be bold (not things like string or number functions that perform calculations).

Platform: GNU/Linux @ i386


回答1:


Quickly hacked up trivial sampling profiler for linux: http://vi-server.org/vi/simple_sampling_profiler.html

It appends backtrace(3) to a file on SIGUSR1, and then converts it to annotated source.

As it probes the program periodically, we'll see functions that waits for something.

And as it walks the stack, we'll see callers too.

Also people from answers to similar questions recommends Zoom.




回答2:


There's no real way to answer that question without knowing your platform and a little more about what you are trying to do.

When I'm running on an Intel platform, I like to use the Time Stamp Counter (RDTSC). It is tough to beat resoultion in the sub-microsecond range. I just put a call to it before and after a chunk of code, and compare the difference.



来源:https://stackoverflow.com/questions/3992587/what-profiler-should-i-use-to-measure-real-time-including-waiting-for-syscall

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!