matlab tic toc function and computer stand-by

1.1k Views Asked by At

I am running a matlab program that its run-time is high(several days). I measure the run-time of various steps of the program using tic and toc functions. sometimes I stand-by or hibernate my laptop to transport it safely. my question is that is stand-by has any effect on the measured elapsed time by tic-toc functions?

thank you!

1

There are 1 best solutions below

0
On

Plus on the testing comment! But here's some reading:

http://www.mathworks.com/company/newsletters/articles/improvements-to-tic-and-toc-functions-for-measuring-absolute-elapsed-time-performance-in-matlab.html

In short, tic/toc are based on high-res timers provided by the OS. gettimeofday() in the case of Linux, and QueryPerformanceCounter() on Windows. Both of these APIs deal in wall-clock time (not CPU time, nor direct cycle counts), so I would expect your test to show that tic and toc keep counting while your computer is asleep and not doing any computation.

One way around this could be to measure tic/toc in small increments of code that are guaranteed to finish in somewhere between a few seconds to a few minutes. Then, toss any results that are larger than some safe runtime threshold (5 minutes? 10 minutes?) as having been interrupted by a suspend before aggregating or reporting the time results.