Linuxでのミリ秒単位の時間取得

#include
#include

double time_diff( struct timeval*, struct timeval*);
main() {
struct timeval t1, t2;
gettimeofday(&t1, NULL);
gettimeofday(&t2, NULL);
printf("%f\n",time_diff(&t1,&t2)/1000000.0);

}

double time_diff( struct timeval *st, struct timeval *et ) {
return (double) ( et->tv_sec - st->tv_sec ) * 1000000 + ( et->tv_usec - st->tv_usec );
}

こんなん。。。
メモ