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

3 次查看(过去 30 天)
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.

采纳的回答

Voss
Voss 2022-5-28
"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');

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by