Re: Way to retrieve the value of %time?

MinRK <[email protected]> Thu, 16 Jul 2015 11:29:21 -0700
Newsgroups gmane.comp.python.ipython.user
Message-ID <CAHNn8BUOB9C7TvptG+7z0RNrq4sKKdKvfoqn+XmDsLiL62Lo9A@mail.gmail.com>
--===============1716764570==
Content-Type: multipart/alternative; boundary=047d7bea43d62bf2f1051b0241fc

--047d7bea43d62bf2f1051b0241fc
Content-Type: text/plain; charset=UTF-8

%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 <[email protected]> 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
> [email protected]
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
>

--047d7bea43d62bf2f1051b0241fc
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">%time doesn&#39;t return a useful struct, but %timeit does=
, now. We should probably do the same thing for %time.<div><br></div><div>-=
MinRK</div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">=
On Thu, Jul 16, 2015 at 11:22 AM, Francesc Alted <span dir=3D"ltr">&lt;<a h=
ref=3D"mailto:[email protected]" target=3D"_blank">[email protected]</a>&gt;<=
/span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8=
ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Hi,<div><b=
r></div><div>I am trying to come up with a way of accessing the time measur=
ed by the magic %time.=C2=A0 That is, in:</div><div><br></div><div>In [149]=
: %time sum(i for i in xrange(1000000))<div>CPU times: user 118 ms, sys: 27=
.4 ms, total: 145 ms</div><div>Wall time: 121 ms</div><div>Out[149]: 499999=
500000</div><div><br></div><div>is there a way to get the 121 ms value of t=
he &#39;Wall time&#39; above and put that in a variable?=C2=A0 I know I can=
 use something like:</div><div><br></div><div><div>In [150]: from time impo=
rt time</div><div><br></div><div>In [151]: t0 =3D time(); sum(i for i in xr=
ange(1000000)); mytime =3D time() - t0</div><div><br></div><div>In [152]: m=
ytime</div><div>Out[152]: 0.10076594352722168</div></div><div><br></div><di=
v>but %time is so much convenient, specially for tutorials, that I would ra=
ther prefer using it.</div><div><br></div><div>Thanks!</div><span class=3D"=
HOEnZb"><font color=3D"#888888"><div><br></div>-- <br><div>Francesc Alted</=
div>
</font></span></div></div>
<br>_______________________________________________<br>
IPython-User mailing list<br>
<a href=3D"mailto:[email protected]">[email protected]</a><br>
<a href=3D"http://mail.scipy.org/mailman/listinfo/ipython-user" rel=3D"nore=
ferrer" target=3D"_blank">http://mail.scipy.org/mailman/listinfo/ipython-us=
er</a><br>
<br></blockquote></div><br></div>

--047d7bea43d62bf2f1051b0241fc--

--===============1716764570==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
IPython-User mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/ipython-user

--===============1716764570==--