clock.c 304 B

12345678910111213141516
  1. static struct timeval tm1;
  2. static inline void start_clock()
  3. {
  4. gettimeofday(&tm1, NULL);
  5. }
  6. static inline void stop_clock()
  7. {
  8. struct timeval tm2;
  9. gettimeofday(&tm2, NULL);
  10. unsigned long long t = 1000 * (tm2.tv_sec - tm1.tv_sec) + (tm2.tv_usec - tm1.tv_usec) / 1000;
  11. printf("%llu ms\n", t);
  12. }