mojo
mojo copied to clipboard
[Feature Request] `%%timeit` magic function in notebook cells for benchmarking
Request
Add support for import time
or %time (%timeit) magic function
Motivation
Performance claim challenge
Description and Requirements
Update the Mandelbrot notebook to display execution time using whatever method is easiest for you to support.
Also, the Benchmark being used in the examples on playground to compute time is unclear. Does it need to wrap the function being called into another function for benchmarking?
Also, the Benchmark being used in the examples on playground to compute time is unclear. Does it need to wrap the function being called into another function for benchmarking?
It appears so. The Benchmark.run() function is parameterized by a function with a fixed signature which is
func: fn() capturing -> None
Even if the function you are benchmarking has the same signature, it might not be possible to call it directly from Benchmark.run() because of the requirement of the function being "capturing". So at the moment it seems to be a requirement to do it that way. I think by adding the @always_inline
decorator we are avoiding the costs of those wrapper function calls, so we don't need to worry about it impacting the actual measurements being made by the benchmark.
We already have from Time import now
, which isn't quite the same as Python's time
module, but you can always import that via the Python interop API. Retitling this to the special %%timeit
command.