Why is the execution time to compute the value of sum getting smaller and smaller every time in the following code? And how to get consistency? Thank you very much for your help.
In[18]:= Quit[]
In[1]:= atime = AbsoluteTiming;
In[2]:= m = 1350; k = 10^4;
In[3]:= LaunchKernels[] // atime
Out[3]= {3.11965, {"KernelObject"[1, "local"],
"KernelObject"[2, "local"], "KernelObject"[3, "local"],
"KernelObject"[4, "local"], "KernelObject"[5, "local"],
"KernelObject"[6, "local"]}}
In[4]:= ClearSystemCache[]
sum = ParallelSum[
1/be Log[10^8 - (be - 1)^2/4] // N[#, k] &, {be, 2, m}]; // atime
Out[5]= {0.905762, Null}
In[6]:= ClearSystemCache[]
sum = ParallelSum[
1/be Log[10^8 - (be - 1)^2/4] // N[#, k] &, {be, 2, m}]; // atime
Out[7]= {0.359625, Null}
In[8]:= ClearSystemCache[]
sum = ParallelSum[
1/be Log[10^8 - (be - 1)^2/4] // N[#, k] &, {be, 2, m}]; // atime
Out[9]= {0.250268, Null}
In[10]:= ClearSystemCache[]
sum = ParallelSum[
1/be Log[10^8 - (be - 1)^2/4] // N[#, k] &, {be, 2, m}]; // atime
Out[11]= {0.167734, Null}
In[12]:= ClearSystemCache[]
sum = ParallelSum[
1/be Log[10^8 - (be - 1)^2/4] // N[#, k] &, {be, 2, m}]; // atime
Out[13]= {0.0718937, Null}
In[14]:= ClearSystemCache[]
sum = ParallelSum[
1/be Log[10^8 - (be - 1)^2/4] // N[#, k] &, {be, 2, m}]; // atime
Out[15]= {0.0620984, Null}
ParallelEvaluate[ClearSystemCache[]]
between your tries? $\endgroup$ – Albert Retey Oct 14 '16 at 17:13ClearSystemCache
to handle the parallel kernels as well, but obviously they decided not to, maybe for good reasons... $\endgroup$ – Albert Retey Oct 17 '16 at 7:14