What is a child function?

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.

 采纳的回答

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 个评论

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?
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()

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by