calculation time in for loop

5 ビュー (過去 30 日間)
yuuki harada
yuuki harada 2020 年 7 月 30 日
コメント済み: yuuki harada 2020 年 7 月 31 日
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?

採用された回答

Adam Danz
Adam Danz 2020 年 7 月 30 日
編集済み: Adam Danz 2020 年 7 月 30 日
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 件のコメント
yuuki harada
yuuki harada 2020 年 7 月 31 日
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!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by