Every "optimization" claim in this whole curriculum, quantization is faster, kernel fusion saves memory traffic, a vectorized loop beats a naive one, is worthless without an actual, repeatable measurement backing it up. This question builds the one small, reusable tool that makes any such claim checkable: a harness that runs a piece of code several times, records real wall-clock timings, and summarizes them honestly.
Implement time_function (running a zero-argument callable several times, recording each run's duration) and benchmark_statistics (summarizing those raw timings).
time_function(fn, num_runs=5) calls fn() exactly num_runs times, returning a list of num_runs individual wall-clock durations (using time.perf_counter()), never a single averaged number.benchmark_statistics(times) returns a dict with keys "mean", "median", "min", "max", "std".Open one at a time. Each gives away a little more than the last.
time.perf_counter() before and after calling fn(), subtracted, gives one run's duration: repeat that num_runs times, appending each duration to a list.
benchmark_statistics is five one-line NumPy calls (.mean(), np.median(), .min(), .max(), .std()) on the same array of times, packaged into a dict.
No results yet
Run your code to check it against the examples, or submit to run every test.