Skip to content

Conversation

@Satyam12singh
Copy link
Contributor

Proposed Changes:
This PR updates the timing logic in several benchmark scripts to use time.perf_counter() instead of time.time().

Files modified:

  • benchmarks/python/comparative/bench_mlx.py
  • benchmarks/python/comparative/bench_torch.py
  • benchmarks/python/time_utils.py
  • docs/src/dev/extensions.rst
  • examples/python/linear_regression.py

Why this is necessary:

  1. Monotonicity: time.time() can be affected by system clock updates (NTP sync), whereas time.perf_counter() is a monotonic clock that never goes backward.
  2. Precision: High-performance kernels (like those in MLX and Torch) require the highest resolution possible to calculate accurate "msec" per iteration.
  3. Consistency: This aligns the benchmarking utility functions with the style already adopted in the rest of the MLX examples.

Checklist

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant