execution speed changes by sequence of running the code

1 回表示 (過去 30 日間)
hamed amini
hamed amini 2017 年 4 月 4 日
回答済み: Steven Lord 2017 年 4 月 4 日
the question updated: the sequence of running different codes changes the run time.
--------------
initially it appeared to be due to difference in file name: any similar experience? changing the function name is changing the execution time (picture attached).
  2 件のコメント
Steven Lord
Steven Lord 2017 年 4 月 4 日
What else was running on your machine when you ran HAPP_dry_KX3 that was not running when HAPP_dry_KX1 was running? Include Windows "phoning home" to look for updates, virus scanners scanning your machine, etc.
Had you run HAPP_dry_KX1 prior to capturing that picture, then run HAPP_dry_KX3 for the first time while generating that picture? If so, in a new MATLAB session try running HAPP_dry_KX3 multiple times then run HAPP_dry_KX1 for the first time.
hamed amini
hamed amini 2017 年 4 月 4 日
- Tnx. Closed the Matlab session and opened a new one. The timing became the same indeed (both took the longer time).
- computer is not busy with other applications
- These (HAPP_dry_KX1 & HAPP_dry_KX3) are part of optimization algorithms with rather large parameter space (7-D). I also have another version of the optimization algorithm (HAPP_dry_KX2 & HAPP_dry_KX4) with less number of variables (shorter run time). After running HAPP_dry_KX1 and HAPP_dry_KX3 several time, I ran HAPP_dry_KX2, and again HAPP_dry_KX1 and HAPP_dry_KX3; this time both (1 & 3) have shorter run time.
- It seems the sequence of running of these codes makes a difference; however could not find the logic behind this behavior.

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

採用された回答

Steven Lord
Steven Lord 2017 年 4 月 4 日
There is some first run overhead (see the "Tips for Measuring Performance" section of that page.) So if you compare the Nth (N > 1) run of one function and the 1st run of another function that contains the same code in a different file, in the latter case you'll measure the overhead in addition to the execution of the code.

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by