有关VTune API的接口使用 – 由用户来控制性能数据的收集

intel_zhenyuwang 2008-04-10 04:37:54
Pause 和 Resume API 给了C/C++程序员机会去控制VTune Analyzer 样本的收集。例如,用户可以在程序中调用VTuneAPI以选择保存想要的数据(一个Benchmark程序不是所有部分都做测量)。这个功能支持IA32,Intel64,安腾,在
• VTune Performance Analyzer for Windows*
• VTune Performance Analyzer for Linux*

怎样让Pause, Resume API 工作?
VTune API 有二类”暂停/恢复”数据采集:VTPause() and VTResume(), 工作于 sampling, counter-monitor, 和 call-graph.而另一类,VTPauseSampling() and VTResumeSampling() 仅工作于sampling.

使用这些APIs,在你的C/C++源代码作以下修改
#include “vtuneapi.h”
Insert calls to VTResume() to resume
recording data:
VTResume();
Insert calls to VTPause() to pause recording data:
VTPause();
如:
void RecordData() { for (int i=0; i<10000000L; i++); }
void DontRecordData() { for (int i=0; i<10000000L; i++); }

int _tmain(int argc, _TCHAR* argv[])
{
// must start with vtune paused here!
VTResume();
RecordData();
VTPause();

DontRecordData();

VTResume();
Record();
VTPause();

return 0;
}

在 Visual Studio*, 用 /I 选项设定 <VTune installation directory>\Analyzer\Include 作为编译环境的”include directory”. 用 <VTune installation directory>\Analyzer\Lib作为编译环境的/libpath. 最后, 增加 VTuneAPI.lib 到<linker input modules> 列表.

VTune 项目创建的改变
避免在应用程序初始化时记录性能数据,设定暂停状态-检查Start with data collection paused 选项在Advanced Activity Configuration对话框, [img=http://photo12.hexun.com/p/2008/0410/187175/b_4C67DC32A2BD722E164E3B8D2FB42435.jpg]看下图[/img].
...全文
230 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
intel_zhenyuwang 2008-04-14
  • 打赏
  • 举报
回复
有没有做Benchmark的朋友愿意尝试一下?针对感兴趣的代码进行性能测试。

567

社区成员

发帖
与我相关
我的任务
社区描述
英特尔® 边缘计算,聚焦于边缘计算、AI、IoT等领域,为开发者提供丰富的开发资源、创新技术、解决方案与行业活动。
社区管理员
  • 英特尔技术社区
  • shere_lin
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧