title: Timing Execution Speed of Python Code
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2866380/python-time-a-code-segment-for-testing-performance-with-timeit">Python: Time a code segment for testing performance (with timeit)</a>  </p>
  </blockquote>
  
  
  
  <p>In C++, you can time blocks of code fairly easily, see code below. Is there any way to do this python? (easily) Thanks!</p>
  
  <pre><code>time_t startTime = clock();
  
  // Do stuff
  
  time_t endTime = clock();
  
  cout &lt;&lt; "Difference in time(milliseconds) : " &lt;&lt; endTime - startTime &lt;&lt; endl;
  </code></pre>