what is time efficiency

1 Ansicht (letzte 30 Tage)
aya qassim
aya qassim am 20 Jan. 2019
Beantwortet: John D'Errico am 20 Jan. 2019
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 Kommentar
Rik
Rik am 20 Jan. 2019
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)

Melden Sie sich an, um zu kommentieren.

Antworten (1)

John D'Errico
John D'Errico am 20 Jan. 2019
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.

Kategorien

Mehr zu Performance and Memory finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by