[SciPy-user] More on speed comparisons

David Cournapeau david@ar.media.kyoto-u.ac...
Mon Jun 16 10:12:43 CDT 2008

Ivo Maljevic wrote:
> Aside from good speed with SciPy (I feel embarrassed that I made that 
> 'sum' mistake)

No need to be embarrassed, I think most of us went through the same.

> time command (e.g., time python ./rand_test_2.py). While you may find 
> this methodology incorrect,
> I do the same with fortran and C code (time ./rand_test_c or time 
> ./rand_test_f).

It may be correct depending on what you want to measure: here you are 
measuring start up times (which is negligeable for C and fortran on a 
decent OS if you are not running cold, that is the C /F runtime is 
already in memory; it is really hard not to have the C runtime already 
loaded on unix :) ).

Numpy startup time is significant for such short computations (a few 
seconds). If for some reason you need to call the script often, it may 
be the good way to measure things. If you just want to benchmark 
different methods, that's certainly the wrong approach, and Gael's one 
is the right one. What you are doing is similar to matlab -r, except 
that python is much more powerful for scripting here.

> Some of my matlab simulation run for more than one hour and I use 
> tic/toc there.

On matlab, I think you should use cputime, but I cannot find this 
recommendation in matlab's online help anymore.



More information about the SciPy-user mailing list