Algorithm timing in Python
<p>I want to compute how many times my computer can do <code>counter += 1</code> in one second. A naive approach is the following:</p>

<pre><code>from time import time

counter = 0
startTime = time()

while time() - startTime &lt; 1:
    counter += 1

print counter
</code></pre>

<p>The problem is <code>time() - startTime &lt; 1</code> may be considerably more expensive than <code>counter += 1</code>.</p>

<p>Is there a way to make a less "clean" 1 sec sample of my algorithm?</p>
