title: Testing the performance of a C++ app
body: <p>I'm trying to find a way to test how long it takes a block of C++ code to run. I'm using it to compare the code with different algorithms and under different languages, so ideally I would like a time in seconds / milliseconds. In Java I'm using something like this:</p>
  
  <pre><code>long startTime = System.currentTimeMillis();
  
  function();
  
  long stopTime = System.currentTimeMillis();
  long elapsedTime = stopTime - startTime; 
  </code></pre>
  
  <p>Is there a good way to get an accurate time like that in C++ (Or should I use some other means of benchmarking)?</p>