the timeit module timeit() method returns the total time, but ipython %timeit returns much more information f.e.
In [17]: %timeit sa.sum()
560 µs ± 9.74 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
is there a standalone %timeit python implementation that you can use in your app ?
posted the solution in my blog. thanks
I am not aware of anything standalone, but this can be easily extracted out of IPython, most of what it does is in the
TimeitResultclass which formats the output https://github.com/ipython/ipython/blob/8520f3063ca36655b5febbbd18bf55e59cb2cbb5/IPython/core/magics/execution.py#L55-L104Then there's the nicer reporting of the compile time, worst run being much worse than the fastest, and getting the run number automatically like timeit's cli.
Reusing the code from IPython and python's timeit, and removing some checks that are probably unnecessary for the common use, we can get a simple function to do the timing in the same way IPython does: