fork(3) download
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <math.h>
  4.  
  5. int main()
  6. {
  7. int i, j;
  8. long t1, t2, t3;
  9. double r = 0;
  10.  
  11. t1 = clock();
  12.  
  13. for (i = 0; i < 10; ++i)
  14. {
  15. for (j = 0; j < 100000000; ++j)
  16. {
  17. r += cos(1);
  18. }
  19. }
  20.  
  21. t1 = clock() - t1;
  22. printf("test1 = %f microseconds\n", 1e6f * (float)t1 / CLOCKS_PER_SEC);
  23.  
  24. t2 = clock();
  25.  
  26. for (i = 0; i < 100000000; ++i)
  27. {
  28. for (j = 0; j < 10; ++j)
  29. {
  30. r += cos(1);
  31. }
  32. }
  33.  
  34. t2 = clock() - t2;
  35. printf("test2 = %f microseconds, debug: %f\n", 1e6f * (float)t2 / CLOCKS_PER_SEC, r);
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 3.65s 3460KB
stdin
Standard input is empty
stdout
test1 = 1825948.000000 microseconds
test2 = 1824508.000000 microseconds, debug: 1080604611.755329