title: How to measure execution time in C on Linux
body: <p>I am working on encryption of realtime data. I have developed encryption and decryption algorithm. Now i want to measure the execution time of the same on Linux platform in C. How can i correctly measure it ?. I have tried it as below</p>
  
  <pre><code>             gettimeofday(&amp;tv1, NULL);
           /* Algorithm Implementation Code*/
               gettimeofday(&amp;tv2, NULL);
  
          Total_Runtime=(tv2.tv_usec - tv1.tv_usec) +          
                        (tv2.tv_sec - tv1.tv_sec)*1000000);
  </code></pre>
  
  <p>which gives me time in microseconds. Is it correct way of time measurement or i should use some other function? Any hint will be appreciated.</p>