How to evaluate overall memory consumption and number of computations of a code?

1 次查看(过去 30 天)
Hi, I am trying to compare two different image processing techniques, the performance results of which are identical. But I need to compare coding performance on the scale of memory consumption and the number of computations involved. Is it possible in matlab?

回答(3 个)

KSSV
KSSV 2017-3-8
To check the performance of code read about profile. for memory related read about whos, memory.

Walter Roberson
Walter Roberson 2017-3-8
No.
If you are using MS Windows then you can call memory() at various times. However that will not tell you peak memory use, as many operations create temporary results. Os-x and Linux do not have access to this call.
It has not really been feasible to measure operations used since MIPS introduced multiple execution units in their CPUs in the early 1990s. Some people would push the date even further back to the introduction of the Sun Microsystems SPARC in the mid 1980s.
There is a third party package that you can use to sort of annotate your code, and it can count theoretical floating point operations for a few standard calculations. It cannot, for example, tell you how efficient the \ operation is.

Jan
Jan 2017-3-8
compare coding performance on the scale of memory consumption and the number of computations
involved. Is it possible in matlab?
No. The term "memory consumption" is not exactly defined. It matters if the chunks of the processed data match into a cache-line, or the other memory caches, or if temporary memory must be stored by disk swapping. Loading large files consumes temporary memory by the automatic disk-caching controlled by the operating system. This can have side-effects for the dynamic allocation of memory inside Matlab also.
The number of computations can change with the processor and the size of the input data in a non-linear way: Some Matlab function use multi-threaded methods if the input size exceeds a certain limit. And as soon as multi-threading is applied, "number of computations" is not exactly defined anymore.
I examined exactly, the definition and determination of the computational performance becomes an extremely complicated problem. So start at defined, what you exactly need for you comparisons. Using a stop watch might be the most reliable technique.

类别

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