calculation time in for loop

4 Ansichten (letzte 30 Tage)
yuuki harada
yuuki harada am 30 Jul. 2020
Kommentiert: yuuki harada am 31 Jul. 2020
For example, when I doubled the number of loops, it is suposed that the computation time also doubled. However the computation time was less than twice.
The computation time for each loop has some variation, but as a whole, the later the loop, the shorter the computation time becomes.
the details of the program can't disclose for a number of reasons, but there's no factor that reduces the computation time which depends on the number of loops.
Is the "for loop" in MATLAB done some process behind the scenes to reduce the computation time?
Also, is there any way to check what kind of calculations are being made internally?

Akzeptierte Antwort

Adam Danz
Adam Danz am 30 Jul. 2020
Bearbeitet: Adam Danz am 30 Jul. 2020
If the computations done within the loops are nearly uniform in their complexity, then it's expected that the speed of each loop will increase (become faster) as the number of iterations increase.
This is because of my friend Justin. Justin Time.
Recent releases of Matlab use Just-in-time (JIT) compilation in all Matlab code [see Matlab execution engine]. From that page,
"The performance benefit of JIT compilation is greatest when MATLAB code is executed additional times and can re-use the compiled code. This happens in common cases such as for-loops or when applications are run additional times in a MATLAB session with at least some of the application’s MATLAB files remaining unmodified between subsequent runs."
For more info on JIT, see Loren Shure's blog post: Run Code Faster With the New MATLAB Execution Engine.
  1 Kommentar
yuuki harada
yuuki harada am 31 Jul. 2020
Thank you for your kind explanation!
I will learn more about JIT.
I had a similar hypothesis, but I couldn't clarify what actually happend.
Thank you once again!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by