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!