Fw: GNU Octave vs. Matlab calculation time performance

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Fw: GNU Octave vs. Matlab calculation time performance

"Gökhan Sen"
Hello,
 
I've send my fit also to Mr. Eaton, but maybe there are other support available,
which could be also helpfull!
 
Many thx. in advance,
 
Kind regards, 
Gökhan Sen
 
Gesendet: Mittwoch, 27. Februar 2019 um 14:58 Uhr
Von: "Gökhan Sen" <[hidden email]>
An: [hidden email]
Betreff: GNU Octave vs. Matlab calculation time performance
Hello Mr. Eaton,
 
I'm a big fan from gnu octave and the very impressive possible usuabla applications.
 
But sometimes it seems, that the calculation speed lacks in comparison with commercial Version e.g. Matlab.
 
I've add a simple script (also as m-file), which is do a simple calculation operation.
 
The calculation time / output from these script as following is:
 
@Matlab (MATLAB Version: 9.0.0.341360 (R2016a))
" Number of vector rows: 
     10000000
Elapsed time is 0.152188 seconds."
 
 
@ GNU Octave 5.1.0:
" Number of vector rows:
  10000000
Elapsed time is 71.7445 seconds."
 
It would mean Matlab do the same calculation operation ~472 time faster as gnu octave... :(
 
This is a simple operation and I use really complex operations and the calculation time will never ends...

Do you have any idea how could I reduce the calculation time and are ther some intentions
for future versions to improve the calculation time to be more closer to Matlab...?
 
I would be very happy, if you could help me about this topic?
 
 
Nevertheless, many thanks for your time and support!
 
Kinde regards,
Gökhan Sen
 

% -------------------------------------------------------------------------
% -------------------------------------------------------------------------
clc
clear all
% -------------------------------------------------------------------------
n = 1e7 ;
V = ones(n,1) ;
R = size(V,1) ;
disp('                        ') ;
disp(' Number of vector rows: ') ;
disp('                        ') ;
disp(R) ;
% -------------------------------------------------------------------------
tic
for k = 1:R
   
    V(k) = 1.2345 * V(k) ;
    
end
toc
% -------------------------------------------------------------------------
% -------------------------------------------------------------------------

 



Memory.m (737 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: GNU Octave vs. Matlab calculation time performance

Windhorn, Allen E [ACIM/LSA/MKT]
Gökhan,

From: Help-octave [mailto:help-octave-bounces+allen.windhorn=[hidden email]] On Behalf Of "Gökhan Sen"

> ...The calculation time / output from these script as following is:
 
@Matlab (MATLAB Version: 9.0.0.341360 (R2016a))
" Number of vector rows: 
     10000000
Elapsed time is 0.152188 seconds."
 
@ GNU Octave 5.1.0:
" Number of vector rows:
  10000000
Elapsed time is 71.7445 seconds."
 
-----
@ Gnu Octave 4.4.1:
tic
V = V.*1.2345;
toc
Elapsed time is 0.039151 seconds.
-----
Can you "vectorize" your code to take advantage of the way Octave/Matrix
works?

I think Matlab may have just-in-time compilation going on, which speeds up
the code tremendously.

Regards,
Allen

Reply | Threaded
Open this post in threaded view
|

Re: Fw: GNU Octave vs. Matlab calculation time performance

nrjank
In reply to this post by "Gökhan Sen"
On Wed, Feb 27, 2019 at 9:29 AM "Gökhan Sen" <[hidden email]> wrote:
Hello,
 
I've send my fit also to Mr. Eaton, but maybe there are other support available,
which could be also helpfull!
 
Many thx. in advance,
 
Kind regards, 
Gökhan Sen
 
Gesendet: Mittwoch, 27. Februar 2019 um 14:58 Uhr
Von: "Gökhan Sen" <[hidden email]>
An: [hidden email]
Betreff: GNU Octave vs. Matlab calculation time performance
Hello Mr. Eaton,
 
I'm a big fan from gnu octave and the very impressive possible usuabla applications.
 
But sometimes it seems, that the calculation speed lacks in comparison with commercial Version e.g. Matlab.
 
I've add a simple script (also as m-file), which is do a simple calculation operation.
 
The calculation time / output from these script as following is:
<snip>

 The example you had demonstrates the simple fact that matlab and octave are generally optimized for vectorized code, and your loop performs one element at a time an operation that can be trivially done without a loop. e.g., replace your for loop with :

V = 1.2345 .* V

and you will notice that both Matlab and Octave perform the operation very quickly.

matlab has managed to implement a Just In Time compiler that likely looks at the for loop and optimizes it for higher speed vectorized calculation.   Octave does not have a functioning JIT compiler yet, and as such it's looped performance suffers greatly.  This is a known current limitation.  Calculations will be correct, but those that rely on heavily looped, non-vectorized, code will be slower.  Such is the reality of an all volunteer programming effort.