#include <stdlib.h> #include <stdio.h> #include <sys/time.h> int main() { struct timeval dwStart; struct timeval dwEnd; unsigned long dwTime=0; int i=0,j=0; gettimeofday(&dwStart,NULL); for(i=0;i<100000;i++) { ; } gettimeofday(&dwEnd,NULL); dwTime = 1000000*(dwEnd.tv_sec-dwStart.tv_sec)+(dwEnd.tv_usec-dwStart.tv_usec); printf("%ld/n",dwTime); return 0; }