Skip to content

Instantly share code, notes, and snippets.

@plmi
Last active October 31, 2022 20:48
Show Gist options
  • Save plmi/38e9d1c1d074413b61adaf6d6ae0ade8 to your computer and use it in GitHub Desktop.
Save plmi/38e9d1c1d074413b61adaf6d6ae0ade8 to your computer and use it in GitHub Desktop.
FLOP Benchmark with numpy
#!/usr/bin/env python3
import time
import numpy as np
N = 4096
A = np.random.randn(N, N).astype(np.float32)
B = np.random.randn(N, N).astype(np.float32)
# number of multiplications
flop = N*N*2*N
for i in range(10):
start_time = time.monotonic()
C = A @ B
end_time = time.monotonic()
time_diff = end_time - start_time
print(f"{flop / time_diff * 1e-12:.2f} TFLOP/S")
@plmi
Copy link
Author

plmi commented Oct 31, 2022

On a Thinkpad T440p with an i7-4800MQ I get:

0.25 TFLOP/S
0.25 TFLOP/S
0.26 TFLOP/S
0.25 TFLOP/S
0.19 TFLOP/S
0.21 TFLOP/S
0.26 TFLOP/S
0.26 TFLOP/S
0.20 TFLOP/S
0.21 TFLOP/S

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