title: Why is CLOCKS_PER_SEC not the actual number of clocks per second?
body: <p>I have just written this short C++ program to approximate the actual number of clock ticks per second.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;time.h&gt;
  
  using namespace std;
  
  int main () {
  
      for(int i = 0; i &lt; 10 ; i++) {
  
          int first_clock = clock();
          int first_time = time(NULL);
  
          while(time(NULL) &lt;= first_time) {}
  
          int second_time = time(NULL);
          int second_clock = clock();
  
          cout &lt;&lt; "Actual clocks per second = " &lt;&lt; (second_clock - first_clock)/(second_time - first_time) &lt;&lt; "\n";
  
          cout &lt;&lt; "CLOCKS_PER_SEC = " &lt;&lt; CLOCKS_PER_SEC &lt;&lt; "\n";
  
      }
  
      return 0;
  
  }
  </code></pre>
  
  <p>When I run the program, I get output that looks like this.</p>
  
  <pre><code>Actual clocks per second = 199139
  CLOCKS_PER_SEC = 1000000
  Actual clocks per second = 638164
  CLOCKS_PER_SEC = 1000000
  Actual clocks per second = 610735
  CLOCKS_PER_SEC = 1000000
  Actual clocks per second = 614835
  CLOCKS_PER_SEC = 1000000
  Actual clocks per second = 642327
  CLOCKS_PER_SEC = 1000000
  Actual clocks per second = 562068
  CLOCKS_PER_SEC = 1000000
  Actual clocks per second = 605767
  CLOCKS_PER_SEC = 1000000
  Actual clocks per second = 619543
  CLOCKS_PER_SEC = 1000000
  Actual clocks per second = 650243
  CLOCKS_PER_SEC = 1000000
  Actual clocks per second = 639128
  CLOCKS_PER_SEC = 1000000
  </code></pre>
  
  <p>Why doesn't the actual number of clock ticks per second match up with CLOCKS_PER_SEC? They're not even approximately equal. What's going on here?</p>