[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: compare the executive speed with Matlab
From: |
Jordi Gutiérrez Hermoso |
Subject: |
Re: compare the executive speed with Matlab |
Date: |
Fri, 2 Jan 2009 13:21:20 -0600 |
2009/1/2 John W. Eaton <address@hidden>:
> On 2-Jan-2009, Sergei Steshenko wrote:
>
> | Well, IIRC, if I need to calculate, say, 'sin' function for a vector of
> | ~150000 elements, 'octave' speed is ~5 times slower than the one of the
> | equivalent code in "C".
>
> How about posting an actual working example so we can see exactly what
> it is you are comparing? Perhaps you are doing something stupid, and
> your comparison is not valid. Or perahaps there is a good reason that
> Octave must do extra work compared to the C version.
It's quite easy to come up with this example. In fact, he more or less
gave the example. He's talked about this example before in the mailing
list too.
In Octave,
octave:1> v = [1:15e6];
octave:2> tic, sin(v); toc;
Elapsed time is 1.39321 seconds.
In C,
#include <math.h>
int main(){
int N = 15000000;
int i;
double d;
for(i = 0; i < N; i++)
d = sin( (double) i);
}
then
address@hidden:~$ gcc foo.c -o foo -lm && time foo
real 0m1.035s
user 0m1.024s
sys 0m0.012s
It's not a very noticeable difference, but I do wonder why there is
one at all.
- Jordi G. H.
- compare the executive speed with Matlab, Howard, 2009/01/01
- Re: compare the executive speed with Matlab, Michael Goffioul, 2009/01/02
- Re: compare the executive speed with Matlab, Sergei Steshenko, 2009/01/02
- Re: compare the executive speed with Matlab, John W. Eaton, 2009/01/02
- Re: compare the executive speed with Matlab, Sergei Steshenko, 2009/01/02
- Re: compare the executive speed with Matlab,
Jordi Gutiérrez Hermoso <=
- Re: compare the executive speed with Matlab, Sergei Steshenko, 2009/01/02
- Re: compare the executive speed with Matlab, John W. Eaton, 2009/01/02
- Re: compare the executive speed with Matlab, Jordi Gutiérrez Hermoso, 2009/01/02
- Re: compare the executive speed with Matlab, Sergei Steshenko, 2009/01/02
- Re: compare the executive speed with Matlab, John W. Eaton, 2009/01/02
- Re: compare the executive speed with Matlab, Sergei Steshenko, 2009/01/02
- Re: compare the executive speed with Matlab, wim van hoydonck, 2009/01/02
- Re: compare the executive speed with Matlab, John W. Eaton, 2009/01/02
- Re: compare the executive speed with Matlab, Sergei Steshenko, 2009/01/02
- Re: compare the executive speed with Matlab, Sergei Steshenko, 2009/01/02