问题描述
我已经在一些项目中使用了Octave和MATLAB,但遇到了一些问题.这个问题为什么/何时/比起Octave,我更喜欢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...
我已经阅读了很多文章/其他资料,比较了Octave和MATLAB的性能,并在标准脚本上运行了一些自己的测试,这些测试证实了普遍的共识,即Octave在标准操作方面通常比MATLAB慢得多(当然要重复一下,这样比较才有意义).
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).
共识也似乎表明,MATLAB的大部分性能提升都归因于其JIT编译器,该JIT编译器在运行时编译大型循环.这是有道理的,并且在这些情况下似乎会出现最大的性能差异(例如 Mathworks Matlab与Gnu Octave )
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)
我的问题如下:为什么在Octave中矢量化代码也运行得更慢?在这种情况下,似乎应该在循环之前留出内存,并由某些本机C/C ++循环执行该操作,这将等同于Octave和MATLAB的矢量化代码性能.另外,这是否具有更广泛的含义,即即使编写了不需要/不使用JIT编译器的代码,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?
推荐答案
Matlab代码有四种加速方式:
There are four ways how Matlab code gets sped up:
-
JIT:根据我的轶事观察,运行时编译有助于循环,但似乎也可以加快(或至少与)代码的其他部分交互.
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.
在C/C ++中实现函数:在Matlab/Octave中实现了一堆Matlab/Octave函数.在每个版本中,都有很多内置的内置组件.
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.
所有这些方法都需要开发人员专门致力于使代码更快.据我所知,Octave开发人员的主要关注点是确保(Matlab)功能完全存在,而性能的提高似乎是最近几年Matlab开发的重点.
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.
这篇关于为什么Octave比MATLAB慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!