Why Octave is a bit slow

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Why Octave is a bit slow

Mudit Sharma
All,

I was recently visiting this page about Julia ( language ) :
https://julialang.org/
and came to know that Octave is slower as compared to others ( please see the table given on the page ).
 I would like to know why Octave becomes slower at times and what can be done to make it faster ?

--
Mudit

Reply | Threaded
Open this post in threaded view
|

Re: Why Octave is a bit slow

Richard Crozier
On 28/04/17 07:59, Mudit Sharma wrote:

> All,
>
> I was recently visiting this page about Julia ( language ) :
> https://julialang.org/
> and came to know that Octave is slower as compared to others ( please
> see the table given on the page ).
>  I would like to know why Octave becomes slower at times and what can be
> done to make it faster ?
>
> --
> Mudit
>


Probably because the benchmarks mostly use looped code which Octave is
not optimised for. Octave would probably not perform so badly with code
optimised for it, e.g. vectorised, for example it is much faster on the
matrix multiplication. However, another reason for the difference is the
lack of JIT functionality in Octave. If you have the capability or
funding to bring this to Octave it would be a fantastic addition!

I had a look at their benchmark code, here:

https://github.com/JuliaLang/julia/blob/master/test/perf/micro/perf.m

as one example, pisum, has a vectorised version which they currently
don't mention:

comparing in Octave, their own two benchmark codes on my machine:

 >> function s = pisumvec(ignore)

     a = [1:10000];

     for j=1:500

         s = sum( 1./(a.^2));

     end

end

 >> function sum = pisum(ignore)

     sum = 0.0;

     for j=1:500

         sum = 0.0;

         for k=1:10000

             sum = sum + 1.0/(k*k);

         end

     end

end

 >> tic; pisum; toc;

Elapsed time is 10.2683 seconds.
 >> tic; pisumvec; toc;

Elapsed time is 0.0357349 seconds.


Regards,

Richard

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


Reply | Threaded
Open this post in threaded view
|

Re: Why Octave is a bit slow

Juan Pablo Carbajal-2
On Fri, Apr 28, 2017 at 9:29 AM, Richard Crozier <[hidden email]> wrote:

> On 28/04/17 07:59, Mudit Sharma wrote:
>>
>> All,
>>
>> I was recently visiting this page about Julia ( language ) :
>> https://julialang.org/
>> and came to know that Octave is slower as compared to others ( please
>> see the table given on the page ).
>>  I would like to know why Octave becomes slower at times and what can be
>> done to make it faster ?
>>
>> --
>> Mudit
>>
>
>
> Probably because the benchmarks mostly use looped code which Octave is not
> optimised for. Octave would probably not perform so badly with code
> optimised for it, e.g. vectorised, for example it is much faster on the
> matrix multiplication. However, another reason for the difference is the
> lack of JIT functionality in Octave. If you have the capability or funding
> to bring this to Octave it would be a fantastic addition!
>
> I had a look at their benchmark code, here:
>
> https://github.com/JuliaLang/julia/blob/master/test/perf/micro/perf.m
>
> as one example, pisum, has a vectorised version which they currently don't
> mention:
>
> comparing in Octave, their own two benchmark codes on my machine:
>
>>> function s = pisumvec(ignore)
>
>     a = [1:10000];
>
>     for j=1:500
>
>         s = sum( 1./(a.^2));
>
>     end
>
> end
>
>>> function sum = pisum(ignore)
>
>     sum = 0.0;
>
>     for j=1:500
>
>         sum = 0.0;
>
>         for k=1:10000
>
>             sum = sum + 1.0/(k*k);
>
>         end
>
>     end
>
> end
>
>>> tic; pisum; toc;
>
> Elapsed time is 10.2683 seconds.
>>> tic; pisumvec; toc;
>
> Elapsed time is 0.0357349 seconds.
>
>
> Regards,
>
> Richard
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
>
Has somebody already posted this code on their repository so they have
better benchmarks?

Reply | Threaded
Open this post in threaded view
|

Re: Why Octave is a bit slow

roland65
In reply to this post by Mudit Sharma
Mudit Sharma wrote
Octave is slower as compared to others
I've done some benchmarks last year. Here is the link : MATLAB / Octave / Scilab benchmarks.

However, I didn't compare with Julia because there was no Julia code for the benchmark programs I used.

As you can see in these benchmarks, Octave is only slow when using loops. Vectorizing loops can be a solution.