How to measure the time of adding elements into a numpy array in Python

1 Answer

0 votes
import time
import numpy as np

start = time.time()

arr = np.array([])
for i in range(50000):
    arr = np.append(arr, i)
    
end = time.time()

print (end - start, "seconds")




'''
run:

3.0867960453033447 seconds

'''

 



answered Mar 3, 2023 by avibootz
...