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.