How to measure memory usage and power consumption for an algorithm programmed with Matlab??

7 次查看(过去 30 天)
I want to know if there is any method that enables me to determine the amount of memory used by an algorithm i built with Matlab (not all Matlab as a package but application programmed with Matlab), besides Power consumption due to running this algorithm. please help. thanks in advance.

回答(1 个)

Jan
Jan 2014-12-29
It depends on the exact definition of "memory usage" and "power consumption". Look at this example:
v = [];
for k = 1:1e3
v = [v, rand];
end
At the end you have a vector of only 8kb (8 byte per double), but intermediately the computer must allocate and copy sum(1:1000)*8 bytes, which are more than 4MB. It depends on the operating system and other threads if freed memory is reused later on. So what exactly is "the memory usage"?
A similar problem appears for the power consumption. Modern processors adjust the working frequency to the load and the current temperature. The relation between power consumption and processing speed is not linear and it depends on the load of the other cores and the GPU also, if it is included in the processor. It matters if the processor waits for data coming from the slow RAM or if the data exist in the caches already. In consequence the total power consumption depends on the OS, other threads, the temperature inside and outside the computer and the efficiency of the power supply.
Finally the results of the measurements might depend more on the exact definition than on the used algorithm. Therefore I suggest not to invest any time for such assessments. Even measuring the processing steps versus the data size, (the big-O value) is of limited use, when the processor cache and virtual memory on hard disks must be considered.

类别

Help CenterFile Exchange 中查找有关 GPU Computing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by