


# https://www.globalsino.com/ICs/page4853.html
# Speed comparison

import time
import numpy as np

A = np.random.rand(10000000)

# Count time for sum(A)
# start time in second since 1970
start_1 = time.time()

sum(A)

# stop time in second since 1970
stop_1 = time.time()
time_1 = stop_1-start_1

print('Time of without_np is ', (round(100*time_1)/100), 'seconds')

# Count time for np.sum(A)
start_2 = time.time()

np.sum(A)

stop_2 = time.time()
time_2 = stop_2-start_2

print('Time of with_np is ', (round(100*time_2)/100), 'seconds')

print('Ratio of times of without_np/with_np is ', round(time_1/time_2), 'times')
