开发者

Varying performance of MSVC release exe

I am curious what could be the reason for highly varying performance of the same executable. Sometimes, I run it and it takes 20 seconds and sometimes it is 110. Source is compiled with MSVC in Release mode with standard options.

The code is here:

vector<double> Un;
vector<double> Ucur;
double *pUn, *pUcur;
...
// time marching
for (old_time=time-logfreq, time+=dt; time <= end_time; time+=dt)
  {
    for (i=1, j=Un.size()-1, pUn=&Un[1], pUcur=&Ucur[1]; i < j; ++i, ++pUn, ++pUcur)
      {
        *pUcur = (*pUn)*(1.0-0.5*alpha*( *(pUn+1) - *(pUn-1) ));
      }
    Ucur[0] = (Un[0])*(1.0-0.5*alpha*( Un[1] - Un[j]   ));
    Ucur[j] = (Un[开发者_JAVA技巧j])*(1.0-0.5*alpha*( Un[0] - Un[j-1] ));
    Un = Ucur;
  }

EDIT

Sorry not to mention input data. The vectors Un and Ucur are initialized to 2000 elements with value 0. No data is read/written. No interaction with console. When I say sometimes I run it means that I have console open, no other applications running , processor throttling disabled. I keep executing application after it finishes. I guess it has to do with caching or something like that but I am not good on low-level things.


I would guess this is because you are loading a large amount of data from a storage device. If there is a lot of contention for the storage device then things will run more slowly as your software needs to wait its turn to do some loading.


Issue was resolved when I switched the arguments in this function from addresses to variables. Before I had double &time, double &dt, double &end_time
Now: double time, double dt, double end_time

It appears to be memory-related issue... Hope, it helps anybody

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜