Can MATLAB save the Profiler results table (Function Name, Calls, etc.) to a text file or a spreadsheet?

8 次查看(过去 30 天)
Can MATLAB save the Profiler results table (Function Name, Calls, Total Time, Self Time) to a text file or a spreadsheet?
I need this to merge and compare Profiler results from different software versions.
  15 个评论
Leigh Sneddon
Leigh Sneddon 2022-2-28
I cannot see an "Accept this answer" button for you, only for the other contributor. How do I accept your answer and/or vote for you?

请先登录,再进行评论。

采纳的回答

Ive J
Ive J 2022-3-1
info = load("info.mat").info;
infotab = struct2table(info.FunctionTable);
infotabMain = infotab(:, ["FunctionName", "NumCalls", "TotalTime", "TotalRecursiveTime"]); % main table in profile viewer
infotabExc = cell(height(infotab), 1); % execution time per each subfunction
for i = 1:height(infotab)
infotabExc{i} = infotab.ExecutedLines{i};
infotabExc{i} = array2table(infotabExc{i}, ...
'VariableNames', {'Line Number', 'Calls', 'Total time(s)'});
end

更多回答(2 个)

Sulaymon Eshkabilov
编辑:Sulaymon Eshkabilov 2022-2-21
Yes, it can be done realtively easy with profsave(profile()), e.g.:
profile on
x = linspace(0, 1, 2e3);
y = sin(2*pi*t)+randn(size(x));
plot(x,y), grid on
profile off
% All html files are saved in your current directory and inside a folder called: MY_Profile_results
profsave(profile('info'),'MY_Profile_Results')

Sulaymon Eshkabilov
You can try this fcn - extracthmltext() to extract the data from html formatted file:
https://www.mathworks.com/help/textanalytics/ref/htmltree.extracthtmltext.html

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by