Borrar filtros
Borrar filtros

how to save number of function calls from profile

2 visualizaciones (últimos 30 días)
H D
H D el 17 de Ag. de 2016
Comentada: Philip Borghesani el 18 de Ag. de 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?

Respuestas (1)

Philip Borghesani
Philip Borghesani el 17 de Ag. de 2016
Editada: Philip Borghesani el 17 de Ag. de 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 comentarios
H D
H D el 18 de Ag. de 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 el 18 de Ag. de 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]

Iniciar sesión para comentar.

Categorías

Más información sobre Performance and Memory en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by