Why is there a time difference in tic toc in multiple runs

조회 수: 1 (최근 30일)
Pallavi Jain
Pallavi Jain 2016년 2월 2일
댓글: Walter Roberson 2016년 2월 2일
In the following code, the execution time returned by tic toc varies in each run. Why?
tic ones(50) toc

답변 (1개)

Rick Rosson
Rick Rosson 2016년 2월 2일
Because tic toc measures elapsed time rather than cpu time. Try using profile instead.
  댓글 수: 3
Steven Lord
Steven Lord 2016년 2월 2일
What if during one iteration your computer "phones home" looking for updates but during another it doesn't?
What if instead it's your virus scanner that is checking for updates?
What if during one iteration tic "starts timing" exactly at the start of one clock tick and ends at the end of that same tick, but during another it starts in the middle of one tick and ends in the middle of another?
The times returned should be very similar but they're not going to be identical unless everything about your system is exactly the same. If you had a VM, saved its state, and restored back to that state that would probably be about as close as you could get to that scenario.
Walter Roberson
Walter Roberson 2016년 2월 2일
What if your computer has to get busy popping up Clippy to remind you that you have not saved a document?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by