End line taking huge amount of time in profiler

조회 수: 28 (최근 30일)
Andreas Badea
Andreas Badea 2016년 6월 22일
답변: Philip Borghesani 2016년 6월 22일
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
dpb
dpb 2016년 6월 22일
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...

댓글을 달려면 로그인하십시오.

답변 (1개)

Philip Borghesani
Philip Borghesani 2016년 6월 22일
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.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by