Prof- C/C++ 分析工具库
C/C++ 性能测试和优化
共0Star
详细介绍
Prof 是 Linux 的自容器 C/C++ 分析工具库。
Prof 提供一个快速的方法来度量 C/C++ 代码片段的性能事件 (CPU 时钟周期等等) 。
小示例:
#include "prof.h"int main()
{ PROF_START(); // slow code goes here...
PROF_STDOUT();
}
自定义选项
#include <stdio.h>
#define PROF_USER_EVENTS_ONLY
#define PROF_EVENT_LIST \
PROF_EVENT_CACHE(L1D, READ, MISS) \
PROF_EVENT_CACHE(L1D, WRITE, MISS)
#include "prof.h"
int main()
{
uint64_t faults[2] = { 0 };
PROF_START();
// slow code goes here...
PROF_DO(faults[index] += counter);
// fast or uninteresting code goes here...
PROF_START();
// slow code goes here...
PROF_DO(faults[index] += counter);
printf("Total L1 faults: R = %lu; W = %lu\n", faults[0], faults[1]);
}
安装
wget -q https://raw.githubusercontent.com/cyrus-and/prof/master/prof.h