フィルターのクリア

How can I show how much time is left for a script to complete?

55 ビュー (過去 30 日間)
Mirage
Mirage 2012 年 11 月 5 日
コメント済み: Paulo Abelha 2016 年 9 月 17 日
I know there's a function call 'waitbar'; however, I want to show whoever is running my script how much time is left before it will be finished. It is a long script that consists of many different functions and loops.
Thanks, Mirage
  3 件のコメント
Mirage
Mirage 2012 年 11 月 7 日
Hi Dave,
The script is pretty long, roughly 900 lines and it's not contained in a for loop so it would be tough to tic toc the first iteration and judge it based on that.
Paulo Abelha
Paulo Abelha 2016 年 9 月 17 日
Hi Dave,
I've coded a function that might help you:
https://uk.mathworks.com/matlabcentral/fileexchange/59187-displayestimatedtimeofloop--tot-toc--curr-ix--tot-iter--

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

回答 (2 件)

Chad Greene
Chad Greene 2012 年 11 月 6 日
Clever use of tic and toc may provide an estimate of how much time the script has been running, and how much time is left.
tic
steps = 10;
for step = 1:steps
% [calculations here]
if step==1
toc1=toc;
end
time_elapsed = toc;
estimated_time_remaining = (steps-step)*toc1;
disp([num2str(time_elapsed),' seconds down, ',num2str(estimated_time_remaining),' seconds to go!'])
end

John Petersen
John Petersen 2012 年 11 月 6 日
One thing you can do is determine where the bulk of the computation time resides. Hopefully this is in a loop. You could then time each loop and then display the time left based on how many iterations remain. Otherwise, it's going to vary too much from computer to computer to be very useful.

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by