How do you return computational time and memory allocated during function call?

I am trying to save the computational time and memory allocated during a function call to two variables (that can then be saved to a text file). How do I return both, as well as the normal output of my function, when calling my function?

回答(1 个)

There are a few functions you can use for timing, one of which is the tic, toc pair. Most current recommendations are to use duration arrays for this, although in the past, using clock and etime were appropriate.
For memory usage, the memory and inmem funcitons are available.
There may be File Exchange contributions that could do what you want, so search there as well.
.

类别

帮助中心File Exchange 中查找有关 Performance and Memory 的更多信息

产品

版本

R2023b

标签

提问:

2025-2-28

Community Treasure Hunt

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

Start Hunting!

Translated by