how to save number of function calls from profile
1 次查看(过去 30 天)
显示 更早的评论
I am using profile function in matlab. first I use profile on and then I run the function that I want statistics about it. I use profileview to see the profiled process. In the Profile Summary page, the column "calls" is what I am interested in. how can I record the number of calls which is in Profile Summary using matlab commands?
0 个评论
回答(1 个)
Philip Borghesani
2016-8-17
编辑:Philip Borghesani
2016-8-17
Use the results returned by profile('info').
profile on; magic(3) ; profile off;
ifo=profile('info');
ifo.FunctionTable(1)
struct with fields:
CompleteName: 'L:\work\Bscript2\matlab\toolbox\matlab\elmat\magic.m>magic'
FunctionName: 'magic'
FileName: 'L:\work\Bscript2\matlab\toolbox\matlab\elmat\magic.m'
Type: 'M-function'
Children: [1×1 struct]
Parents: [0×1 struct]
ExecutedLines: [3×3 double]
IsRecursive: 0
TotalRecursiveTime: 0
PartialData: 0
NumCalls: 1
TotalTime: 0.0120
The number of calls in in the field NumCalls
2 个评论
Philip Borghesani
2016-8-18
Data for other functions is at other indexes into the function table, you can examine the full output with struct2table(ifo.FunctionTable) or {ifo.FunctionTable.FunctionName;ifo.FunctionTable.NumCalls}'.
>> {ifo.FunctionTable.FunctionName;ifo.FunctionTable.NumCalls}'
ans =
2×2 cell array
'magic' [1]
'magic>oddOrderMagicSquare' [1]
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call C++ from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!