I need to test the performance of code that will be objective and roughly the same across all machines. Timing code does not work since it's tied to your or mine machine specs, but counting instructions issued by a CPU does (with minor differences).
I can use strace in Linux, but my god its slow and I just want total not individual calls.
Say:
def foo(bar):
for i in range(bar):
print(i)
foo(10)
This will execute at different speeds on different machines (bear with me, imagine a more complicated algorithm). But the amount of operation done is the same, 10 ios. This is important because if you have a faster computer you won't notice a millisecond that might take 5 seconds on my machine.
Is there a way to count # of CPU instructions done since in Python?
I'm asking because I want to know if a refactor will 2x my CPU instructions.
Thank you.