Skip to content

Instantly share code, notes, and snippets.

@nschloe
Created May 14, 2021 14:05
Show Gist options
  • Save nschloe/d093057ef912faf1c1636b394e5bf412 to your computer and use it in GitHub Desktop.
Save nschloe/d093057ef912faf1c1636b394e5bf412 to your computer and use it in GitHub Desktop.
np.dot vs blas.ddot
import numpy as np
import perfplot
from scipy.linalg.blas import ddot
def np_dot(data):
x, y = data
return np.dot(x, y)
def sp_ddot(data):
x, y = data
return ddot(x, y)
b = perfplot.bench(
setup=lambda n: np.random.rand(2, n),
kernels=[np_dot, sp_ddot],
n_range=[2 ** k for k in range(24)],
)
b.save("out.png")
b.show()
@nschloe
Copy link
Author

nschloe commented May 14, 2021

out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment