| Last Modified On : | October 15, 2009 3:26 AM PDT |
Rate |
|
// testVTuneAPI.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "VtuneApi.h"
int _tmain(int argc, _TCHAR* argv[])
{
U32 u32Return;
VTUNE_EVENT events[] = {
{ 10000, 0, 0, 0, "CPU_CLK_UNHALTED.CORE" }, // Sample After Value, Reserved, Reserved, Return Status, Event Name - my system is Intel(R) Core(TM) 2 Duo
{ 10000, 0, 0, 0, "INST_RETIRED.ANY" }, // Use "vtl query -c sampling" to know all supported events in the system, in command prompt
};
U32 numEvents = sizeof(events) / sizeof(VTUNE_EVENT);
VTUNE_SAMPLING_PARAMS params = {
sizeof(VTUNE_SAMPLING_PARAMS),
sizeof(VTUNE_EVENT),
0, // sampling options
0, // reserved
0, // If 1, start sampling in pause mode
0, // maximum number of samples to be collected.
1000, // number of samples per buffer
40, // the sampling interval in milliseconds
1, // "1" for event based sampling
numEvents, // number of events
events, // event list array
"results.tb5", // result file with simple or full path
0, // reserved
0, // "1" - generate a count file "tb5Filename.txt"
"" // CPU mask
};
u32Return = VTStartSampling(¶ms); // start sampling since it is not in pause mode
if (u32Return) {
printf("Can't start sampling\n");
exit(0);
}
for (int i=0; i<10000000L; i++); // do some work, data is captured
VTPauseSampling(); // pause data collection
for (int i=0; i<10000000L; i++); // do some work, data is NOT captured
VTResumeSampling(); // resume data collection
for (int i=0; i<10000000L; i++); // do some work, data is captured again
u32Return = VTStopSampling(1); // stop collecting data and write result into TB5 file, use VTune(TM) Analyzer to import it!
if (u32Return) {
printf("Can't stop sampling\n");
exit(0);
}
return 0;
}

English | 中文 | Русский | Français
Peter Wang (Intel)
|