I know I can use timeit like this:
timeit.timeit("f(x)", "from __main__ import f", number=100000)
And this will repeat f()
100000 times.
However, I'd like to do something like this:
timeit.timeit("f()", "from __main__ import f", duration=5000)
Which would repeat f()
as much as necessary until it hits 5 seconds.
Is there something like this in timeit or would I have to craft a while-loop myself?