[Numpy-discussion] best way of counting time and cputime?

bernhard.voigt at gmail.com bernhard.voigt at gmail.com
Mon May 14 07:13:20 EDT 2007


> Is the genutils module not included to standard CPython edition?

It's not. It's a sub-module of IPython.

It's based on the resource module,though and that comes with Python on
Linux. Just define the function Fernando posted:

> >     def clock():
> >         """clock() -> floating point number
>
> >         Return the *TOTAL USER+SYSTEM* CPU time in seconds since the start of
> >         the process.  This is done via a call to resource.getrusage, so it
> >         avoids the wraparound problems in time.clock()."""
>
> >         u,s = resource.getrusage(resource.RUSAGE_SELF)[:2]
> >         return u+s

Take a look at the module docs of resource.

Bernhard




More information about the NumPy-Discussion mailing list