I'm benchmarking my server using following python code:
import time
initial_clock = time.clock()
res = 0
for i in range(1, 10000000):
res += i * i
print (time.clock() - initial_clock)
When I run it multiple times I get different execution times from 2.163377
seconds to 2.970836
seconds.
I know same code may have different execution time due to variation in CPU load but as is said in time.clock
documentation it only considers current process clocks, so it should have same execution time using time.clock()
even if it is different using time.time()
. shouldn't be?
Also is there anyway I can get exact clock
count for a piece of python code?
EDIT: I use time.process_time()
and get same result.