在Linux中使用硬件性能计数器

Met*_*est 15 c c++ linux multithreading multicore

我想使用Intel和AMD x86_64多核处理器附带的硬件性能计数器来计算程序退役商店的数量.我希望每个线程分别计算其退休商店.可以吗?如果是这样,在C/C++中如何?

osg*_*sgx 10

如果要在内部计算程序某些部分的硬件事件(不启动任何第三方工具),则可以使用Perfctr或PAPI.

Perfctr快速入门:http://www.ale.csce.kyushu-u.ac.jp/~satoshi/how_to_use_perfctr.htm

PAPI主页:http://icl.cs.utk.edu/papi/

PerfSuite好文档:http://perfsuite.ncsa.illinois.edu/publications/LJ135/x27.html

如果您可以在外部执行此操作,则可以使用perf现代Linux.

perf wiki:https://perf.wiki.kernel.org/index.php/Main_Page

  • 很高兴知道`perf`命令.我不知道它存在. (2认同)