refactor: use time.perf_counter for consistent and accurate benchmarking (#2943)

This commit is contained in:
Satyam singh
2025-12-28 19:46:13 +05:30
committed by GitHub
parent 26dfe4f651
commit d9b950eb2f
5 changed files with 10 additions and 10 deletions
+2 -2
View File
@@ -29,12 +29,12 @@ def loss_fn(w):
grad_fn = mx.grad(loss_fn)
tic = time.time()
tic = time.perf_counter()
for _ in range(num_iters):
grad = grad_fn(w)
w = w - lr * grad
mx.eval(w)
toc = time.time()
toc = time.perf_counter()
loss = loss_fn(w)
error_norm = mx.sum(mx.square(w - w_star)).item() ** 0.5