- linux
struct timeval t1, t2;
double timeuse;
gettimeofday(&t1,NULL);
foo();
gettimeofday(&t2,NULL);
timeuse = t2.tv_sec - t1.tv_sec + (t2.tv_usec - t1.tv_usec) / 1000000.0;
printf("%s timeuse = %f s\r\n",__func__, timeuse);
2.QT
QTime time;
time.restart();
... do something
printf("%d ms", time.elapsed());