how to calculate the execution time of program?
114 ビュー (過去 30 日間)
古いコメントを表示
shrivardhan suryawanshi
2014 年 2 月 25 日
回答済み: Steven Lord
2021 年 11 月 12 日
When we get desired output in MATLAB.Then how to calculate execution time in MATLAB...
0 件のコメント
採用された回答
Dishant Arora
2014 年 2 月 25 日
tic
yourCode
timeElapsed = toc
6 件のコメント
AVINASH PANDEY
2021 年 11 月 12 日
thanku for the information. However, if we repeatedly run the code we get different elapsed time each time. Any explanation regarding this will be highly appreciable.
Steven Lord
2021 年 11 月 12 日
Some minor variation is to be expected. One potential cause of variation is different other processes running at the same time your MATLAB code is running. If you're on Microsoft Windows and Windows Update chooses exactly the time you're running your code to "phone home" for updates that obviously consumes some of the computer's attention, thus potentially making your MATLAB code take longer to run.
その他の回答 (3 件)
Aaron Corbin
2014 年 3 月 1 日
編集済み: Aaron Corbin
2014 年 3 月 1 日
You could also do the following:
before1=clock code... etime(clock,before1)
It subtracts the time before from the time after.
0 件のコメント
Laith Mohammed
2019 年 11 月 16 日
First you put tic and entering the code that you are working on it after that toc,
Finaly, create a variable called Elapsed_time = toc
Or, you can just wait and matlab will tell you that elapsed time is (XX seconds)
0 件のコメント
Steven Lord
2021 年 11 月 12 日
tic and toc is one way to measure the performance of your code. Other ways include the timeit function and the Profiler.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Dates and Time についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!