End of function slow - Matlab Profiler
이전 댓글 표시
Hi,
I'm trying to optimize my program, and I'm encountering very curious results with the Profiler. It seems that the end statement in a function is taking significantly longer than any other statement.
Below is an image from the profiler output.
ks is a 1D vector, realKa is a boolean, and everything else is just a scalar.

As you can see, end takes up more time than the two most computationally intensive lines 190 and 198 combined. Why is this?
Note: I'm quite sure it is not because of the profiler, because the profiler said the total time spent in this function was 5.252 seconds, while adding up all the times and rounding up yields 2.47 seconds. Running my program without the profiler speeds things up by close to the difference of 2.782 seconds.
댓글 수: 2
Muthu Annamalai
2013년 7월 25일
According to your profiling results, ~ 1/3 of the calls to err() function do not enter the loop. Also I wonder if having function name, variable name, and the return value set to the same identifier has something to do with it.
I'd be more creative and use different names, assuming there isn't a shortage where you live :-)
Vince
2013년 7월 25일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Common Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!