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

6 ビュー (過去 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 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:
% run a function:
% 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
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:
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:

その他の回答 (0 件)


Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by