Can the Code Profiler be used programmatically to profile an app in App Designer?

3 visualizaciones (últimos 30 días)
I am aware that I can open the Profiler, click 'start profiling' run my app, then stop profilling and view it.
Can I initiate the start and stop of the profiling programatically?
tic/toc is good, but that's better to test implementations. the Profiler is great to look at overall where my code is slow.

Respuesta aceptada

Voss
Voss el 28 de Mayo de 2022
"Can I initiate the start and stop of the profiling programatically?"
Yes. See the "action" input argument part of the documentation for profile:
Using some of those actions, maybe you can do what you want:
% turn on and start the profiler:
profile('on');
profile('resume');
% run a function:
test_func();
% get the current profiler info:
s = profile('info')
s = struct with fields:
FunctionTable: [44×1 struct] FunctionHistory: [4×396 double] ClockPrecision: 1.0000e-06 ClockSpeed: 3.4554e+09 Name: 'MATLAB' Overhead: 0
s.FunctionTable
ans = 44×1 struct array with fields:
CompleteName FunctionName FileName Type Children Parents ExecutedLines IsRecursive TotalRecursiveTime PartialData NumCalls TotalTime
% get the info about the function test_func:
s.FunctionTable(strcmp({s.FunctionTable.FunctionName},'test_func'))
ans = struct with fields:
CompleteName: '/users/mss.system.IR6him/test_func.m>test_func' FunctionName: 'test_func' FileName: '/users/mss.system.IR6him/test_func.m' Type: 'M-function' Children: [0×1 struct] Parents: [1×1 struct] ExecutedLines: [5×3 double] IsRecursive: 0 TotalRecursiveTime: 0 PartialData: 0 NumCalls: 1 TotalTime: 6.6100e-04
% stop the profiler:
profile('off');

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by