Guest User

Untitled

a guest
Feb 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. int main(int argc, char **argv) {
  2. // ProcessTime example
  3.  
  4. struct timeval startTime;
  5. struct timeval endTime;
  6.  
  7. // get the current time
  8. // - NULL because we don't care about time zone
  9. gettimeofday(&startTime, NULL);
  10.  
  11. // algorithm goes here
  12. what_you_want_to_time();
  13.  
  14. // get the end time
  15. gettimeofday(&endTime, NULL);
  16.  
  17. // calculate the time
  18. printf("Execution time: %ld.%d\n", (endTime.tv_sec - startTime.tv_sec), (endTime.tv_usec - startTime.tv_usec));
  19.  
  20. return 0;
  21. }
Add Comment
Please, Sign In to add comment