Question

Given this example code:

start = time.clock()

while (abs(x**2 - userInput) > epsilon):

    x = 0.5 * (x + (userInput/x))
    count = count+1

end = time.clock()

print(end-start)

And given that this operation, take very little time, how can I get a more precise timer?

I have looked at timeit module but could not figure out how to use it or whether it is what I want.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top