Why does Matlab run faster after a script is “warmed up”?

前端 未结 4 739
-上瘾入骨i
-上瘾入骨i 2020-12-05 19:01

I have noticed that the first time I run a script, it takes considerably more time than the second and third time1. The \"warm-up\" is mentioned in this question

4条回答
  •  感动是毒
    2020-12-05 19:18

    Matlab is interpreted. If you don't warm up the code, you will be losing a lot of time due to interpretation instead of the actual algorithm. This can skew results of timings significantly.

    Running the code at least once will enable Matlab to actually compile appropriate code segments.

提交回复
热议问题