Reputation: 14939
I have a function that in turn calls many more functions. I want to use the profiler to identify what parts of the code is most time demanding.
Is it possible to get the profile summary sorted by cells, instead of function calls?
For instance, is it possible to get the profiler to output this:
Cells Calls Total time ...
Part 1 1 .... ...
Part 2 1 .... ...
instead of:
Function name Calls Total time ...
func1 1 .... ...
func2 1 .... ...
For the following code:
%% Part 1:
a = 1;
b = 2;
X = func1(a,b);
%% Part 2:
c = a+b;
Y = func2(c,b);
Thanks!
Upvotes: 1
Views: 121
Reputation: 32930
Well, you can always extract the profiling information for each cell like so:
%% Part 1
profile on
%// Some code...
profile off
S1 = profile('info');
%% Part 2
profile on
%// Some more code...
profile off
S2 = profile('info');
The structures S1
and S2
should hold the profiling information for each cell. Remember to put profile on
and profile off
at the beginning and the end of each code cell to reset the profiling information.
To view the profile information in HTML form, you can use profview
. For example:
profview(0, S1)
The first argument is an index in the FunctionTable
field of the profile information struct, that corresponds to the function you want to display in the profile viewer.
Upvotes: 2