Created
July 11, 2025 06:44
-
-
Save dominikgrygiel/cb4c88b675928959f92bee6f021c723d to your computer and use it in GitHub Desktop.
Numpy "benchmark"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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