what is time efficiency

조회 수: 1 (최근 30일)
aya qassim
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
Rik
Rik 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)

댓글을 달려면 로그인하십시오.

답변 (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.

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by