profile: anomaly when sub functions present
Reported by Alain Lamy
Originally assigned to Simon MARCHETTO
Bug description:
The result of profile/show_profile seems to be wrong when sub-functions are defined in the function that is analysed.
When comparing the results for the functions TEST1 and TEST2, one obsserves that:
- for TEST1, "profile" generates a matrix with as many lines as there are in TEST1,
- for TEST2, the number of lines of the profile result is the number of lines of TEST2 + 1 (strange?)
show_profile simply takes the first N lines of the profile result.
It seems that the profile results do not correspond to the correct lines of the functions when sub functions are defined ("TEST2" case).
// TEST1 : OK
-->disp(x1);
1. 0. 0.
1. 0. 2. <=> w = 1
1. 0.000062 3. <=> sin(a)
1. 0. 0. <=> endfunction
-->showprofile(TEST1);
function z=fun(a)|1|0|0|
w = 1; |1|0|2| <=> w = 1
z = sin(a); |1|0|3| <=> sin(a)
endfunction |1|0|0| <=> endfunction
// TEST2 : NOT OK
-->disp(x2);
1. 0. 0.
0. 0. 0.
0. 0. 0.
0. 0. 0.
1. 0. 5. <======= ????
1. 0. 2. <=> w = 1
1. 0.000062 3. <=> sin(a)
1. 0. 0. <=> endfunction
-->showprofile(TEST2);
function z=fun(a) |1|0|0|
function [b] = F(a)|0|0|0|
b=3; |0|0|0|
endfunction |0|0|0|
w = 1; |1|0|5| ???
z = sin(a); |1|0|2| ???
endfunction |1|0|3| ???
How to reproduce the bug:
function [z] = TEST1(a)
w=1;
z = sin(a);
endfunction
function [z] = TEST2(a)
function [b] = F(a)
b=3;
endfunction
w=1;
z = sin(a);
endfunction
add_profiling("TEST1");
TEST1(1:1000000);
x1 = profile(TEST1);
disp(x1);
showprofile(TEST1);
add_profiling("TEST2");
TEST2(1:1000000);
x2 = profile(TEST2);
disp(x2);
showprofile(TEST2);