Can MATLAB save the Profiler results table (Function Name, Calls, etc.) to a text file or a spreadsheet?
Mostrar comentarios más antiguos
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 comentarios
Ive J
el 21 de Feb. de 2022
You can use profile('info'), and then write what you need to a file. profsave also can save it to an HTML doc.
Leigh Sneddon
el 21 de Feb. de 2022
Leigh Sneddon
el 21 de Feb. de 2022
Ive J
el 21 de Feb. de 2022
I guess you can do something like this
profile on
% your code
info = profile('info');
profile viewer % to compare
infotab = struct2table(info.FunctionTable);
infotabMain = infotab(:, ["FunctionName", "NumCalls", "TotalTime"]); % 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
Leigh Sneddon
el 21 de Feb. de 2022
Ive J
el 21 de Feb. de 2022
Can you upload info?
Leigh Sneddon
el 21 de Feb. de 2022
Leigh Sneddon
el 21 de Feb. de 2022
I get no error:
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
% show me what you got
head(infotabMain)
size(infotabExc)
head(infotabExc{1})
Leigh Sneddon
el 22 de Feb. de 2022
Leigh Sneddon
el 22 de Feb. de 2022
Ooops, my bad!
What about this?
info = load("info.mat").info;
infotab = struct2table(info.FunctionTable);
keepCol = ismember(infotab.Properties.VariableNames, ["FunctionName", "NumCalls", "TotalTime", "TotalRecursiveTime"]);
infotabMain = infotab(:, keepCol); % 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
% show me what you got
head(infotabMain)
Leigh Sneddon
el 22 de Feb. de 2022
Leigh Sneddon
el 28 de Feb. de 2022
Ive J
el 1 de Mzo. de 2022
Posted as an answer. Thanks!
Respuesta aceptada
Más respuestas (2)
Sulaymon Eshkabilov
el 21 de Feb. de 2022
Editada: Sulaymon Eshkabilov
el 21 de Feb. de 2022
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')
1 comentario
Leigh Sneddon
el 21 de Feb. de 2022
Sulaymon Eshkabilov
el 21 de Feb. de 2022
0 votos
You can try this fcn - extracthmltext() to extract the data from html formatted file:
https://www.mathworks.com/help/textanalytics/ref/htmltree.extracthtmltext.html
1 comentario
Leigh Sneddon
el 22 de Feb. de 2022
Categorías
Más información sobre Spreadsheets en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!