Skip to content

Instantly share code, notes, and snippets.

@dominikgrygiel
Created July 11, 2025 06:44
Show Gist options
  • Save dominikgrygiel/cb4c88b675928959f92bee6f021c723d to your computer and use it in GitHub Desktop.
Save dominikgrygiel/cb4c88b675928959f92bee6f021c723d to your computer and use it in GitHub Desktop.
Numpy "benchmark"
# benchmark.py
import time
import numpy as np
def benchmark():
size = 2000
a = np.random.random((size, size))
b = np.random.random((size, size))
start = time.time()
c = np.dot(a, b)
end = time.time()
print(f"Matrix multiplication ({size}x{size}): {end-start:.2f}s")
start = time.time()
u, s, v = np.linalg.svd(a)
end = time.time()
print(f"SVD ({size}x{size}): {end-start:.2f}s")
if __name__ == "__main__":
np.show_config()
print("\n\n")
benchmark()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment