variable inside loop

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Dear all.

I guess the following is somewhat VC specific question ...
Imagine such a code:

for (int a=0; a<1000; a++)
{
int b;
//<== operations on b
}

I've been wondering if there is any speed related benefit if I had declared variable b outside of the loop. So far I haven't spotted any difference in case of basic types. Otherwise, constructor evoked dozens of times would take up loads of the processing time. Can anyone elaborate on how VC copes with variables of basic types declared inside loops rather than outside?

Cheers,
Peter
.



Relevant Pages

  • Re: variable inside loop
    ... I've been wondering if there is any speed related benefit if I had ... declared variable b outside of the loop. ... of times would take up loads of the processing time. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: variable inside loop
    ... I've been wondering if there is any speed related benefit if I had declared variable b outside of the loop. ... constructor evoked dozens of times would take up loads of the processing time. ... Can anyone elaborate on how VC copes with variables of basic types declared inside loops rather than outside? ...
    (microsoft.public.dotnet.languages.vc)
  • Re: fmincon options playing
    ... I'm trying to make my fmincon optimization more efficient by playing ... optimization in a loop where at the end I take the minimum over all ... I don't know how MaxIter and MaxFunEvals affect the processing time. ...
    (comp.soft-sys.matlab)
  • Disregard last msg(but check this one)
    ... I'm trying to make my fmincon optimization more efficient by playing ... optimization in a loop where at the end I take the minimum over all ... I don't know how MaxIter and MaxFunEvals affect the processing time. ...
    (comp.soft-sys.matlab)
  • fmincon options playing
    ... I'm trying to make my fmincon optimization more efficient by playing ... optimization in a loop where at the end I take the minimum over all ... I don't know how MaxIter and MaxFunEvals affect the processing time. ...
    (comp.soft-sys.matlab)