Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Created October 28, 2018 22:34
Embed
What would you like to do?
Comparing the time to do elementwise multiplication
import numpy as np
import time
from multiply import c_multiplication, python_multiplication
a = np.random.rand(2000,2000)
b = np.random.rand(2000,2000)
print("Timing python multiplication:\n")
start = time.time()
python_result = python_multiplication(a, b)
end = time.time()
print(end - start)
print("Timing C multiplication:\n")
c_result = c_multiplication(a, b)
print("Timing numpy multiplication:\n")
start = time.time()
python_result = a * b
end = time.time()
print(end - start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment