Compute time slower with numpy vectorizarion compared to for loops

Hi All Please check out the below discrepancy where vectorization is taking more time. Attaching image


The objects here are really too small to reliably and clearly see the performance difference between loops and vectorized operations. Try your own experiments with vectors with 10^4 or 10^5 elements and see what happens.

You’ll also notice that the measurements have a fair amount of “jitter”: if you run them multiple times, the numbers bounce around a lot.

They claim that python time.process_time is measuring actual cpu time used, but my guess is that fact that we are running on multiple layers of virtualization here is what is causing the unreliability of the numbers. This all runs on AWS and it’s Docker on top of VMs on top of the real linux on the bare metal hardware.