MATLAB Answers


what is time efficiency

aya qassim さんによって質問されました 2019 年 1 月 20 日
最新アクティビティ John D'Errico
さんによって 回答されました 2019 年 1 月 20 日
hey there,
how can I know what is the time efficiency of a function in matlab
for example I want to know whether the function "intersect" in matlab is linear in time or not?
thank you.

  1 件のコメント

2019 年 1 月 20 日
For some functions the algorithm is described in the documentation. For all other functions, you will have to test it yourself (or find someone who has done so already).
Note that implementations of some functions may change from release to release. These changes are likely not mentioned in the doc or release notes. (maybe a casual mention about some functions being optimized)

サインイン to comment.

1 件の回答

John D'Errico
回答者: John D'Errico
2019 年 1 月 20 日

The timing for any function in a tool like MATLAB depends on a huge number of things, not all of which are under the control of The MathWorks.
So what CPU do you have? How many cores are available? Is the function multi-threaded? Does it use operations that are multi-threaded? (Many operations are done so automatically, but only when the problem size issufficiently large for it to be a gain.) How much memory do you have? Cache?
That is just a subset of the machine dependent things I would consider. Then there are problem dependent questions. Some algorithms are problem size dependent, so algorithm switching is sometimes done. And some algorithms are themselves dependent on the data, running more efficiently on some data than on other data.
I'm sure there are some other factors I could think of, given some time. Don't forget things like function call overhead, which for small problems will be a dominant factor. And all of this is surely going to be release dependent for some functions, sicne there can always be changes made to compiled code as supplied.
It also means the only real measure of time is to run a test or series of tests on YOUR machine, on your release, on data that is consistent with the class of problems you will pose. Use the timeit function for the most consistent measure of time used.

  0 件のコメント

サインイン to comment.

Translated by