Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. int time_difference(struct timespec *start, struct timespec *finish,
  2. long long int *difference) {
  3. long long int ds = finish->tv_sec - start->tv_sec;
  4. long long int dn = finish->tv_nsec - start->tv_nsec;
  5.  
  6. if(dn < 0 ) {
  7. ds--;
  8. dn += 1000000000;
  9. }
  10. *difference = ds * 1000000000 + dn;
  11. return !(*difference > 0);
  12. }
  13.  
  14. int main() {
  15. int i;
  16. struct timespec start, finish;
  17. long long int time_elapsed;
  18.  
  19. clock_gettime(CLOCK_MONOTONIC, &start);
  20.  
  21. for(i=0;i<n_passwords;i<i++) {
  22. crack(encrypted_passwords[i]);
  23. }
  24.  
  25.  
  26. clock_gettime(CLOCK_MONOTONIC, &finish);
  27. time_difference(&start, &finish, &time_elapsed);
  28. printf("Time elapsed was %lldns or %0.9lfs\n", time_elapsed,
  29. (time_elapsed/1.0e9));
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement