|
Some users prefer to have just one huge project m-file, but as for me, it's more comfortable to have some kind of project tree...
Yet on this way there are some troubles:
1)
Sometimes user has lots of unordered, yet related functions in "project"; just like GUIDE created .m file :
For now, I have to "manually" add ('.\GUI') to PATH , and manually split initial 'GUI.m' to *.m stored there...
You may agree it can be more convenient to have, for example, '#GUI' folder, where
'#' means it'll be automatically added to path, if it's "visible", just like @-class directories.
Or even '#GUI/#init' & '#GUI/#callbacks' ...
2)
Sometimes there are many jumps from one function to function, or method to method for example(well, quite inefficient, but just to show the thing):
function z=get_2(x,y)
globals g1 g2 g3 g4 g5 g6 g7 g8 g9 g10
z=A.get_1(x + g1*g2*g3*g4*g5*g6*g7*g8*g9*g10 , y);
z=z*2;
end
function z=get_1(x,y)
globals g1 g2 g3 g4 g5 g6 g7 g8 g9 g10
z=A.get(x, y + g1*g2*g3*g4*g5*g6*g7*g8*g9*g10);
z=z+1;
end
...
a=A.get_2(x0,y0);
This can be very slow , and not due to really essential calculations, especially for scalar values... There may be simple solution to add some "#inline" tag to methods, which may make above statements equal to
....
globals g1 g2 g3 g4 g5 g6 g7 g8 g9 g10
t=A.get_1(...
x0 + g1*g2*g3*g4*g5*g6*g7*g8*g9*g10,...
y0,....
);
t=t*2;
a=t;
and next step to:
....
globals g1 g2 g3 g4 g5 g6 g7 g8 g9 g10
t=A.get (...
x0 + g1*g2*g3*g4*g5*g6*g7*g8*g9*g10,...
y0 + g1*g2*g3*g4*g5*g6*g7*g8*g9*g10,....
);
t_=t_+1;
t=t_;
t=t*2;
a=t;
According to profiler, this may increase performance of some my scripts up to 200%
The only thing is it's quite annoying and to optimize such things manually, also initial code may have much better readability.....
|