Advertisement
kaspyx

Untitled

Sep 12th, 2013
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1.  
  2.  
  3.  
  4. #include <sys/time.h>                // for gettimeofday() in Linux
  5.                 // QueryPerformanceCounter and QueryPerformanceFrequency for Windows
  6.  
  7.  
  8.     timeval t1, t2;
  9.     double elapsedTime;
  10.  
  11.  
  12.         gettimeofday(&t1, NULL);
  13.  
  14.         gettimeofday(&t2, NULL);
  15.  
  16.         elapsedTime = (t2.tv_sec - t1.tv_sec) * 1000.0;      // sec to ms
  17.         elapsedTime += (t2.tv_usec - t1.tv_usec) / 1000.0;   // us to ms
  18.  
  19.         cout << elapsedTime << " ms.\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement