If you need really precise timer AND if your processor is a Pentium AND if you plan to recompile your code with MSVC you could do as follow :
At the top of your source code type in
#ifndef _CVI_
#define MyRDTSC(var)\
__asm _emit 0x0F \
__asm _emit 0x31 \
__asm mov DWORD PTR var, eax \
__asm mov DWORD PTR var+4, edx
#endif
Somewhere in a callback where you need to measure a timing
int CVICALLBACK OnBlablabla (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){
#ifndef _CVI_
__int64 i64_start, i64_end, i64_diff;
#else
time_t t1, t2;
#endif
#ifndef _CVI_
MyRDTSC(i64_start);
#else
t1=clock();
#endif
MyTestFunction(void);
#ifndef _CVI_
MyRDTSC(i64
_end);
i64_diff = (i64_end - i64_start);
sprintf(cMsg, "Processing request : %d µP cycles", (int)(i64_diff & 0xffffffff));
#else
t2=clock();
sprintf(cMsg, "Processing time : %d ms", t2-t1);
#endif
return(0);
}
Doing so you should be able to compile the code either under CVI or MSVC and take advantage of a very precise timer whenever it make sens.
Regards, Philippe
Feel free to visit http://www.baucour.com