Skip to content

Instantly share code, notes, and snippets.

@nschloe
Created May 13, 2021 11:21
Show Gist options
  • Save nschloe/7e4cb61dd391b4edbeb10d23038aa98e to your computer and use it in GitHub Desktop.
Save nschloe/7e4cb61dd391b4edbeb10d23038aa98e to your computer and use it in GitHub Desktop.
numpy division vs multiplication
import perfplot
import numpy as np
def div(ab):
a, b = ab
return a / b
def mul(ab):
a, b = ab
return a * b
b = perfplot.bench(
setup=lambda n: np.random.rand(2, n),
kernels=[div, mul],
n_range=[2 ** k for k in range(23)],
equality_check=None
)
b.save("out.png")
b.show()
@nschloe
Copy link
Author

nschloe commented May 13, 2021

out

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