mirror of
https://github.com/ml-explore/mlx.git
synced 2025-10-21 01:58:10 +08:00
jagrit's commit files
This commit is contained in:
18
benchmarks/numpy/time_utils.py
Normal file
18
benchmarks/numpy/time_utils.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import time
|
||||
|
||||
|
||||
def time_fn(fn, *args):
|
||||
print(f"Timing {fn.__name__} ...", end=" ")
|
||||
|
||||
# warmup
|
||||
for _ in range(5):
|
||||
fn(*args)
|
||||
|
||||
num_iters = 100
|
||||
tic = time.perf_counter()
|
||||
for _ in range(num_iters):
|
||||
x = fn(*args)
|
||||
toc = time.perf_counter()
|
||||
|
||||
msec = 1e3 * (toc - tic) / num_iters
|
||||
print(f"{msec:.5f} msec")
|
Reference in New Issue
Block a user