CPU-time in Ipython
Hi all, Finally, I have installed IPython via cvs. Again, the question comes up, how to measure the CPU-time which is required to solve the eigenvalue problem. A small example is appreciated from scipy import * w, vr = linalg.eig(A,B) Thanks in advance Nils
Nils Wagner wrote:
Hi all,
Finally, I have installed IPython via cvs.
Again, the question comes up, how to measure the CPU-time which is required to solve the eigenvalue problem.
A small example is appreciated
from scipy import *
w, vr = linalg.eig(A,B)
In [10]: size=100 In [11]: A=RA.random((size,size)) In [12]: B=RA.random((size,size)) In [13]: timing(1,linalg.eig,A,B) Out[13]: 0.10742200000000002 In [14]: size=500 In [15]: A=RA.random((size,size)) In [16]: B=RA.random((size,size)) In [17]: timing(1,linalg.eig,A,B) Out[17]: 23.265625 From the docstring: In [18]: timing? Type: function Base Class: <type 'function'> String Form: <function timing at 0x81c37d4> Namespace: Interactive File: /usr/local/home/fperez/code/python/IPython/genutils.py Definition: timing(reps, func, *args, **kw) Docstring: timing(reps,func,*args,**kw) -> t_total Execute a function reps times, the elapsed total CPU time in seconds. This is just the first value in timings_out(). You'll need to import timing and friends first, they live in IPython.genutils. Best, f.
Fernando Perez schrieb:
Nils Wagner wrote:
Hi all,
Finally, I have installed IPython via cvs.
Again, the question comes up, how to measure the CPU-time which is required to solve the eigenvalue problem.
A small example is appreciated
from scipy import *
w, vr = linalg.eig(A,B)
In [10]: size=100
In [11]: A=RA.random((size,size))
In [12]: B=RA.random((size,size))
In [13]: timing(1,linalg.eig,A,B) Out[13]: 0.10742200000000002
In [14]: size=500
In [15]: A=RA.random((size,size))
In [16]: B=RA.random((size,size))
In [17]: timing(1,linalg.eig,A,B) Out[17]: 23.265625
From the docstring:
In [18]: timing? Type: function Base Class: <type 'function'> String Form: <function timing at 0x81c37d4> Namespace: Interactive File: /usr/local/home/fperez/code/python/IPython/genutils.py Definition: timing(reps, func, *args, **kw) Docstring: timing(reps,func,*args,**kw) -> t_total
Execute a function reps times, the elapsed total CPU time in seconds. This is just the first value in timings_out().
You'll need to import timing and friends first, they live in IPython.genutils.
Best,
f.
But, what can I do to obtain the CPU-time of a whole sequence of different functions, i.e. t_0= ? while t < tend: several function calls t_1= ? \Delta t = t_1-t_0 I am interested in \Delta t Nils
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.net http://www.scipy.net/mailman/listinfo/scipy-user
Nils Wagner wrote:
But, what can I do to obtain the CPU-time of a whole sequence of different functions, i.e.
t_0= ?
while t < tend:
several function calls
t_1= ?
\Delta t = t_1-t_0
I am interested in \Delta t
Well, timing() times a single function call and returns the time for its execution as a float. So you can: - call it with all your various functions, and add the returned times - write a simple wrap function which calls everything you want in one pass and time that with timing() Alternatively, use the clock() function in genutils (which bypasses the wraparound problems of time.clock() under unix) and do: t0 = clock() ... delta = clock() - t0. Cheers, f.
participants (2)
-
Fernando Perez -
Nils Wagner