How can I "profile" only my .m functions in MATLAB?

I have a relatively large code, and I would like to use a "profile" to improve it. When I use the "profile", I have a report that lists all the functions (built-in and my .m functions) and their corresponding run time.

I would like to list only the functions written by me (and not the built-in ones) and their corresponding run time. Does anyone know how to do this?

Thanks in advance.

+4
source share
2 answers

Are you looking at a profile overview ? If so, then there is a column indicating the total time and time for each function (including your own). I think that time itself may be the time you seek. In addition, you can click on the function name in the left column on the left and see how the time was spent in the code. Be sure to check the Show function list box and update it to view detailed time information in each line of code. Hope this helps.

0
source

Here is an attempt using a 'info'function parameter profile. I drop the matlab functions by comparing their full path name with matlabroot. Here is the code:

profile on

... % Put the code to profile here

% Stop the profiler and get infos
stats = profile('info');

% Sort results based on the total execution time
[~,I] = sort([stats.FunctionTable.TotalTime], 'descend');

for i = I

    % Get file structure
    F = stats.FunctionTable(i);

    % Discard Matlab functions
    if ~isempty(findstr(F.CompleteName, matlabroot))
        continue;
    end

    % Display the total execution time and the function name
    fprintf('%.06f sec\t', F.TotalTime);
    fprintf('%s\n', F.FunctionName);

end

Although the profiler provides a view that looks much nicer, it does what you intended to do.

NB. , exist, core Matlab "". , repmat verLessThan , , .

,

0

All Articles