Xcode Instruments has a tool called Counters that provides low-level counter information provided by the CPU, such as the number of instructions executed or the number of misses in the cache:

This is similar to Linux syscall perf_event_open introduced in Linux 2.6.32. On Linux, I can use perf_event_open , then start / stop profiling around the section of my code that interests me. I would like to write down the same type of statistics in OS X: counting instructions (etc.), that a certain piece of code and getting the result in automatic mode. (I do not want to use the graphical interface of tools for data analysis.)
Are there any APIs that allow this (for example: using dtrace or similar)? From some searches, it sounds as if the private AppleProfileFamily.framework might have the necessary interceptors, but it's unclear how to link or use it.
profiling instruments macos
Sophie Alpert Sep 12 '15 at 7:57 2015-09-12 07:57
source share