Why is the% timeit cycle a different number of times?

In the Jupter Notebook, I tried to compare the time between two index search methods with the maximum value.

enter image description here

In the image, the first function took 1000 cycles, and the second took 10,000 cycles, this is an increase in cycles due to the method itself. OR Jupyter. Just added more cycles to get a more accurate time per cycle, even if the second function is possible, only 1000, is that the case?

+5
source share
2 answers

%timeit library limits the number of runs depending on how long the script takes.

The number of runs can be set with -n. Example:

 %timeit -n 5000 df = pd.DataFrame({'High':[1,4,8,4,0]}) 5000 loops, best of 3: 592 ยตs per loop 
+6
source

It has a built-in option -n: "Options: -n: execute the given instruction times in a loop. If this value is not set, the appropriate value is selected." docs

Thus, it changes the number of cycles, if not specified.

0
source

Source: https://habr.com/ru/post/1270327/


All Articles