End line taking huge amount of time in profiler

24 visualizaciones (últimos 30 días)
Andreas Badea
Andreas Badea el 22 de Jun. de 2016
Respondida: Philip Borghesani el 22 de Jun. de 2016
I was running a script in MatLab (2016a) and it was running incredibly slowly, I ran the profiler and found that two of the lines that were taking the most time were the end lines. This seems incredibly bizarre, what can I do to fix it and why is it so in the first place? Many Thanks
  1 comentario
dpb
dpb el 22 de Jun. de 2016
Note you've got two end statements at lines 24,25 that are called 4158 times; that double loop is the bottleneck. Now what's in there isn't shown but need to investigate what you're doing...perhaps dynamically reallocating an array or somesuch, maybe??? The key is it's not the end itself but what that is encompassing that the profiler can't separate to any finer resolution...

Iniciar sesión para comentar.

Respuestas (1)

Philip Borghesani
Philip Borghesani el 22 de Jun. de 2016
Without seeing the full function all I can do is guess. Typically time shows up in end statements for workspace cleanup when exiting a function and for loop overhead in a for loop. There appears to be too much time in your end statements (for the number of times the line was hit) for it to be simple for loop overhead. I expect something in the code block is creating large objects or structures of objects and cleaning up or maintaining the loop index is taking a long time.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by