How to get elapsed time of a code in matlab ?
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I run a code of two variables which does not contain any function. I simply run a partial differential equation using forward difference farmula inside two loops of time and space. I use 'tic' and 'toc' to get the elapsed time of the code at the end. But I need this time in advance as my code takes hours to give result. Can I get the expected elapsed time in advance ?
4 个评论
dpb
2022-8-1
Just turn off any power-off settings and, of course, be sure the machine is on an UPS so it doesn't lose power.
Then add code to the end of the process that notifies you by <SendTextMessageFromMatlab> when it's done.
Walter Roberson
2022-8-1
How long is it going to take to clean your garage? You are not permitted to use your records of how long it has taken you in the past to clean garages of similar size, and you are not permitted to clean a fraction of the garage and use the timing to estimate the total time.
回答(2 个)
John D'Errico
2022-8-1
Sorry, but no.
A prediction of the time required for some arbitrary piece of code will never happen. It cannot happen. Well, not true. If you run the code in advance, EXACTLY as you will call it, then the predicted time is just the time it took the last time you ran that same problem.
You can run smaller problems, then figure out how the problem size will extrapolate up, but even that is rarely something you can predict at all well.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!