fork(6) download
  1. #include <iostream>
  2. #include <time.h>
  3.  
  4. using namespace std;
  5.  
  6. int main () {
  7.  
  8. for(int i = 0; i < 2 ; i++) {
  9.  
  10. int first_time = time(NULL);
  11. while(time(NULL) <= first_time) {}
  12. int first_clock = clock();
  13. first_time = time(NULL);
  14. while(time(NULL) <= first_time) {}
  15.  
  16. int second_time = time(NULL);
  17. int second_clock = clock();
  18.  
  19. cout << "Actual clocks per second = " << (second_clock - first_clock)/(second_time - first_time) << "\n";
  20.  
  21. cout << "CLOCKS_PER_SEC = " << CLOCKS_PER_SEC << "\n";
  22.  
  23. }
  24.  
  25. return 0;
  26.  
  27. }
Success #stdin #stdout 3.53s 2724KB
stdin
Standard input is empty
stdout
Actual clocks per second = 1000000
CLOCKS_PER_SEC = 1000000
Actual clocks per second = 1000000
CLOCKS_PER_SEC = 1000000