Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
232 views
in Technique[技术] by (71.8m points)

Why is Octave slower than MATLAB?

I have been using Octave and MATLAB for a few projects, and I've come across a few questions. This question Why/when should I prefer MATLAB over Octave?) answered several, but there is still one lingering...

I've read a number of posts/other sources comparing performance of Octave and MATLAB, and I've run some of my own tests on standard scripts that confirm the general consensus that Octave is generally much slower than MATLAB for standard operations (iterated, of course, so that the comparison is meaningful).

The consensus also seems to suggest that most of MATLAB's performance boost is attributable to its JIT compiler, which compiles large loops at runtime. This makes sense, and the largest performance differences appear to occur in these cases (e.g Mathworks Matlab vs Gnu Octave)

My question is the following: why should it be the case that vectorized code also runs more slowly in Octave? It seems that in this case memory should be set aside before the loop and some native C/C++ loop should perform the operation, which would equate performance between Octave and MATLAB for vectorized code. Additionally, does this have broader implications, i.e. that Octave might perform more poorly for complex operations, even if code is written such that a JIT compiler is unneeded/unused?

question from:https://stackoverflow.com/questions/12569351/why-is-octave-slower-than-matlab

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There are four ways how Matlab code gets sped up:

  • JIT: compiling at runtime helps with loops but seems to speed up (or at least interact with) other parts of the code as well, according to my anecdotal observations.

  • Implementing functions in C/C++: There's a bunch of Matlab/Octave functions that are implemented in Matlab/Octave. At every release, there's a bunch more of them that get made into built-ins.

  • Multithreading: There's a list of functions that have multithreaded implementations, which will speed up function calls.

  • Generally more efficient implementations. For example the median filter got a massive speed boost for integer inputs a few releases ago.

All of these approaches need developers dedicated to make code faster. As far as I know, a major concern of Octave developers is to make sure (Matlab) functionality is there at all, whereas performance increase seems to have been a focus of Matlab development in the last few years.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...