Measure time using gettimeofday()

 
#include <iostream>
using namespace std;
#include <sys/time.h>
int main()
{
  struct timeval start, end;
  int millis; 

  gettimeofday( &start, NULL);
  sleep(1);
  gettimeofday( &end, NULL);
  millis = (end.tv_sec - start.tv_sec)*1000 + 
    (end.tv_usec - start.tv_usec)/1000;
  count << "msec: " << millis << endl;
}