This is a static copy of a profile reportHome
ml_getlinept (4349434 calls, 13568.678 sec)
Generated 05-Nov-2014 07:53:20 using cpu time.
function in file /usr0/home/jenkins/workspace/cellorganizer-demo3D11-glnx64/utilities/3D/vesicles/ml_getlinept.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
107 | pts=[pts;s]; | 283749378 | 1856.368 s | 13.7% |  |
96 | pts=[pts;s]; | 278762678 | 1812.848 s | 13.4% |  |
108 | end | 283749378 | 992.323 s | 7.3% |  |
97 | end | 278762678 | 969.301 s | 7.1% |  |
105 | s(2)=s(2)+stepy; | 283749378 | 884.173 s | 6.5% |  |
All other lines | | | 7053.667 s | 52.0% |  |
Totals | | | 13568.678 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
flipud | function | 1078370 | 33.767 s | 0.2% |  |
ml_getlinept | function | 2168688 | 0 s | 0% |  |
Self time (built-ins, overhead, etc.) | | | 13534.911 s | 99.8% |  |
Totals | | | 13568.678 s | 100% | |
Code Analyzer results
Line number | Message |
96 | The variable 'pts' appears to change size on every loop iteration. Consider preallocating for speed. |
107 | The variable 'pts' appears to change size on every loop iteration. Consider preallocating for speed. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 123 |
Non-code lines (comments, blank lines) | 50 |
Code lines (lines that can run) | 73 |
Code lines that did run | 62 |
Code lines that did not run | 11 |
Coverage (did run/can run) | 84.93 % |
Function listing
time calls line
1 function pts=ml_getlinept(s,t)
2 %ML_GETLINEPT Get coordinates of points on a line segment.
3 % PTS = ML_GETLINEPT(S,T) returns the coordinates of points on a line
4 % segment from S to T, which both are integer vectors with length 2.
5 % PTS has two columns indicating X and Y coordinates.
6
7 % Copyright (C) 2007-2012 Murphy Lab
8 % Carnegie Mellon University
9 %
10 % ??-???-???? Initial write T. Zhao
11 % July 17, 2008 I. Cao-Berg
12 %
13 % This program is free software; you can redistribute it and/or modify
14 % it under the terms of the GNU General Public License as published
15 % by the Free Software Foundation; either version 2 of the License,
16 % or (at your option) any later version.
17 %
18 % This program is distributed in the hope that it will be useful, but
19 % WITHOUT ANY WARRANTY; without even the implied warranty of
20 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 % General Public License for more details.
22 %
23 % You should have received a copy of the GNU General Public License
24 % along with this program; if not, write to the Free Software
25 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 % 02110-1301, USA.
27 %
28 % For additional information visit http://murphylab.web.cmu.edu or
29 % send email to murphy@cmu.edu
30
15.92 4349434 31 if nargin < 2
32 error('Exactly 2 arguments are required')
33 end
34
71.05 4349434 35 if any(round([s t])~=[s t])
36 error('the points must be integers');
37 end
38
16.36 4349434 39 if s(1)==t(1)
0.08 24230 40 if s(2)<t(2)
0.29 12114 41 pts=[zeros(t(2)-s(2)+1,1)+s(1),(s(2):t(2))'];
0.03 12114 42 end
0.09 24230 43 if s(2)==t(2)
44 pts=s;
45 end
0.08 24230 46 if s(2)>t(2)
0.17 12116 47 pts=[zeros(s(2)-t(2)+1,1)+s(1),(s(2):-1:t(2))'];
0.07 12116 48 end
0.11 24230 49 return;
50 end
51
14.00 4325204 52 if s(2)==t(2)
0.12 12114 53 pts=ml_getlinept([s(2),s(1)],[t(2),t(1)]);
0.17 12114 54 pts=[pts(:,2),pts(:,1)];
0.02 12114 55 end
56
28.38 4325204 57 if all(s<t)
58 %if isaLinux
59 % if ismac
60 % [pts,npts] = ml_getlinept_mex(s,t);
61 % pts = pts(:,1:npts)';
62 % else
63
64 %old implementation
7.16 2156516 65 dx=t(1)-s(1);
6.90 2156516 66 dy=t(2)-s(2);
67
6.83 2156516 68 if dy < 0
69 dy = -dy;
70 stepy = -1;
6.43 2156516 71 else
6.40 2156516 72 stepy = 1;
6.74 2156516 73 end
74
6.33 2156516 75 if (dx < 0)
76 dx = -dx;
77 stepx = -1;
6.54 2156516 78 else
6.17 2156516 79 stepx = 1;
6.26 2156516 80 end
81
6.48 2156516 82 dy=dy*2;
7.25 2156516 83 dx=dx*2;
84
14.63 2156516 85 pts(1,:)=s;
86
7.43 2156516 87 if (dx > dy)
3.20 1066108 88 fraction = dy - dx/2;
3.66 1066108 89 while (s(1) ~= t(1))
864.64 278762678 90 if fraction >= 0
366.27 115358820 91 s(2)=s(2)+stepy;
354.59 115358820 92 fraction=fraction-dx;
345.42 115358820 93 end
869.86 278762678 94 s(1)=s(1)+stepx;
867.69 278762678 95 fraction=fraction+dy;
1812.85 278762678 96 pts=[pts;s];
969.30 278762678 97 end
3.29 1090408 98 else
3.39 1090408 99 fraction= dx - dy/2;
3.73 1090408 100 while (s(2) ~= t(2))
880.07 283749378 101 if (fraction >= 0)
383.04 120330482 102 s(1)=s(1)+stepx;
366.31 120330482 103 fraction=fraction-dy;
356.69 120330482 104 end
884.17 283749378 105 s(2)=s(2)+stepy;
883.69 283749378 106 fraction=fraction+dx;
1856.37 283749378 107 pts=[pts;s];
992.32 283749378 108 end
109 % end
3.42 1090408 110 end
6.46 2156516 111 end
112
14.20 4325204 113 if s(1)>t(1) && s(2)<t(2)
14.21 1078204 114 pts=ml_getlinept([t(1)-s(1),s(2)],[0,t(2)]);
6.21 1078204 115 pts(:,1)=t(1)-pts(:,1);
3.28 1078204 116 end
117
35.82 4325204 118 if all(s>t) || (s(1)<t(1) && s(2)>t(2))
12.61 1078370 119 pts=ml_getlinept(t,s);
53.86 1078370 120 pts=flipud(pts);
4.73 1078370 121 end
122
26.79 4325204 123 end%ml_getlinept