fork download
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdint>
  4. using namespace std;
  5.  
  6. #define ITERATIONS (1000000000)
  7.  
  8. int main()
  9. {
  10. volatile int64_t x;
  11. clock_t start = clock();
  12. for(int64_t i = ITERATIONS; i > 0;)
  13. {
  14. x = i--;
  15. }
  16.  
  17. auto first_clock = clock() - start;
  18. start = clock();
  19. for(int64_t j = ITERATIONS; j > 0;)
  20. {
  21. x = --j;
  22. }
  23. auto last_clock = clock() - start;
  24.  
  25. cout << first_clock << ' ' << last_clock << std::endl;
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 4.12s 3296KB
stdin
Standard input is empty
stdout
2740000 1370000