Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #define _POSIX_C_SOURCE 199309L
  2. #include <stdio.h>
  3. #include <time.h>
  4.  
  5. int main(int argc,char* argv[])
  6. {
  7. time_t now;
  8. time(&now);
  9. printf("Today is: %s", ctime(&now));
  10.  
  11. for (int i = 0; i < 40; i++) {
  12. if (i % 7 == 0) {
  13. fprintf(stderr, "ERROR: process(%s): %d\n", argv[1], i);
  14. } else {
  15. fprintf(stdout, "process(%s):%d\n", argv[1], i);
  16. }
  17. // sleep for 1/10 second
  18. nanosleep((const struct timespec[]){{0, 100000000L}}, NULL);
  19. }
  20.  
  21. time_t end;
  22. time(&end);
  23. printf("Elapsed time is: %2.3fs\n", difftime(end, now));
  24. printf("Elapsed time is: %2.3fs\n", (double)(end - now));
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement