I want to subtract two gettimeofday instances, and present the answer in milliseconds.
The idea is:
static struct timeval tv;
gettimeofday(&tv, NULL);
static struct timeval tv2;
gettimeofday(&tv2, NULL);
static struct timeval tv3=tv2-tv;
and then convert 'tv3' into milliseconds resolution.
You can use the timersub() function provided by glibc, then convert the result to milliseconds (watch out for overflows when doing this, though!).