How can I know in Python how many times a line of code is executed per minute?
<p>For example if I have:  </p>

<pre><code> something=something+1 
</code></pre>

<p>I want to know how many times in a minute, this line is executed in order to create another variable with this result? </p>

<p>If you are willing to wait a full minute (which usually is not the case) you could do something like</p>

<pre><code>import time
start = time.time()

operationsPerMinute = 0

while (time.time() - start &lt; 60):
    operationsPerMinute = operationsPerMinute + 1

print(operationsPerMinute)
</code></pre>

<p>In which case operationsPerMinute holds the value you want.</p>

<p>Alternatively, you could run in a much smaller time frame and use a bit of math to estimate it in a whole minute time frame. </p>

python loops time