End of function slow - Matlab Profiler
Afficher commentaires plus anciens
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 commentaires
Muthu Annamalai
le 25 Juil 2013
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
le 25 Juil 2013
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Common Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!