When I 'Run and time' a function, and look at the bottom of the profile summary, it says "Self time is the time spent in a function excluding the time spent in its child functions. Self time also includes overhead resulting from the process of profiling. I can have a vague idea as to what it is based on context (i.e. subfunctions), but would like a more rigorous definition of what it is.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 24 Jun. 2016

0 Stimmen

Child functions in this context is any routine that is called. For example,
function test
for K = 1 : 300000
sort(rand(1,K));
end
then "self-time" would be the total time spent executing test minus the time spent executing rand and sort

2 Kommentare

Naveen
Naveen am 24 Jun. 2016
So for example, the following code, when 'run and timed'
A = zeros(length(C) - end_info,n_mnr);
for i =start_row:length(C)
A(i - end_info,:) = str2num(C{i});
end
produces this as one of the lines in the profile summary.
Function Name .......Calls ...... Total Time .......Self Time*
str2num............1048578 ....... 95.887s ........... 22.986s
What would be the child functions for str2num then? Does it refer to functions within the pre-programmed str2num?
Walter Roberson
Walter Roberson am 24 Jun. 2016
Yes, str2num() calls several functions, with the major work being done by eval(), which is relatively inefficient.
Note: if you are concerned about performance you should look at str2double() or sscanf()

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by