[IPython-dev] [IPython-User] Way to retrieve the value of %time?
MinRK
benjaminrk at gmail.com
Thu Jul 16 14:29:21 EDT 2015
%time doesn't return a useful struct, but %timeit does, now. We should
probably do the same thing for %time.
-MinRK
On Thu, Jul 16, 2015 at 11:22 AM, Francesc Alted <faltet at gmail.com> wrote:
> Hi,
>
> I am trying to come up with a way of accessing the time measured by the
> magic %time. That is, in:
>
> In [149]: %time sum(i for i in xrange(1000000))
> CPU times: user 118 ms, sys: 27.4 ms, total: 145 ms
> Wall time: 121 ms
> Out[149]: 499999500000
>
> is there a way to get the 121 ms value of the 'Wall time' above and put
> that in a variable? I know I can use something like:
>
> In [150]: from time import time
>
> In [151]: t0 = time(); sum(i for i in xrange(1000000)); mytime = time() -
> t0
>
> In [152]: mytime
> Out[152]: 0.10076594352722168
>
> but %time is so much convenient, specially for tutorials, that I would
> rather prefer using it.
>
> Thanks!
>
> --
> Francesc Alted
>
> _______________________________________________
> IPython-User mailing list
> IPython-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20150716/cdc2377f/attachment.html>
More information about the IPython-dev
mailing list