title: Using clock() to measure execution time
body: <p>I am running a C program using GCC and a proprietary DSP cross-compiler to simulate some functioality. I am using the following code to measure the execution time of particular part of my program:</p>
  
  <pre><code>clock_t start,end;
  printf("DECODING DATA:\n");
  start=clock();
  conv3_dec(encoded, decoded,3*length,0);
  end=clock();
  duration = (double)(end - start) / CLOCKS_PER_SEC;
  printf("DECODING TIME = %f\n",duration);
  </code></pre>
  
  <p>where <code>conv3_dec()</code> is a function defined in my program and I want to find the run-time of this function.</p>
  
  <p>Now the thing is when my program runs, the <code>conv3_dec()</code> functions runs for almost 2 hours but the output from the <code>printf("DECODING TIME = %f\n",duration)</code> says that the execution of the function finished in just half a second (<code>DECODING TIME = 0.455443</code>) . This is very confusing for me.</p>
  
  <p>I have used the <code>clock_t</code> technique to measure the runtimes of programs previously but the difference has never been so huge. Is this being caused by the cross-compiler. Just as a side note, the simulator simulates a DSP processor running at just 500MHz, so is the difference in the clock speeds of the DSP processor and my CPU causing the error is measuring the CLOCKS_PER_SEC. </p>