Filter löschen
Filter löschen

how to save number of function calls from profile

2 Ansichten (letzte 30 Tage)
H D
H D am 17 Aug. 2016
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?

Antworten (1)

Philip Borghesani
Philip Borghesani am 17 Aug. 2016
Bearbeitet: Philip Borghesani am 17 Aug. 2016
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 Kommentare
H D
H D am 18 Aug. 2016
Hi and thanks for your reply I have a second function inside the file whis is called by the main function based on a condition. lets name it f2. the f2 is called by main function when ever it is required. I need to grab this and to know how many times the f2 is called. i can see it in the Profile Summary file but I need it to be shown in the command window. Thanks once again
Philip Borghesani
Philip Borghesani am 18 Aug. 2016
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]

Melden Sie sich an, um zu kommentieren.

Kategorien

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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by