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

3 ビュー (過去 30 日間)
Michael Van de Graaff
Michael Van de Graaff 2022 年 5 月 23 日
回答済み: Voss 2022 年 5 月 28 日
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 Center および File ExchangeDevelop 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