MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   Why is computation time clustered? (https://www.labfans.com/bbs/showthread.php?t=22150)

poster 2019-11-26 08:42

Why is computation time clustered?
 
<p>So I wanted to record data on how long my computer took to perform a calculation. However, when I record the data (of generating 1,000 uniform random numbers), the actual time the processor takes to do that tends to be clustered around certain values. I.e. it's a multimodal distribution.</p>

<p>Is there a reason why?</p>

<p>Here is my matlab code:</p>

<pre><code>N=10^6;
x=zeros(1,N);
for n=1:N;
tic;
for k=1:1000;
rand;
end;
x(n)=toc;
end;
</code></pre>

<p>Here's a plot of the computation time for 1 million iterates. You can clearly see the banding. This is not really a time series per se, but it also illustrates the correlation between successive iterations too, where the computer must have started on some other task thus changing the time it took for this particular task. Zooming in near t=0 also further illustrates more banding. I suppose matlab tic/toc might have a limited resolution and that could be factor? Should I try to record computation times with another method, or maybe use R instead?</p>

<p><a href="https://i.stack.imgur.com/Bja75.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bja75.png" alt=""time series" of computation time"></a></p>

<p>Suggestions for another venue for this question, or if there is a way to improve its clarity are appreciated as well.</p>



[url=https://stackoverflow.com/questions/59041995/why-is-computation-time-clustered]More answer...[/url]


所有时间均为北京时间。现在的时间是 21:25

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.