Re: copymemory basic question

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



Tony Proctor wrote:
> Although I haven't checked what the VB compiler generates, 'static'
> variables are generally slower in other languages, and for the same
> basic reason: it's the way they're addressed rather than the way
> they're stored or created.

I'd agree with that assessment and your description of the process except that in the particular case that started this subthread, there were no stack variables at all, which means that the function prolog can be skipped. When this is the case, a single static variable ought to be measurably more efficient in a tiny function like this one. The difference between "mov eax, [staticvar]" and "mov eax, [epb-8]" is insignificant.

(I believe TLS is addressed off FS, which would make that "mov eax, FS:[staticvar]", still a minor hit compared to the call to set up a frame.)

What we don't know is whether VB does indeed skip the prolog/epilog when it can. If it doesn't, then there's no advantage (and a slight disadvantage) to using static locals. From the timings, it sure looks as if it doesn't.

--
Jim
.



Relevant Pages

  • Re: Why C?
    ... > C programs can be as fast as a compiler can make them, ... > programs in other languages. ... > lurking bugs and inappropriate data types in any existing C code. ... With only a different declaration syntax it would be much ...
    (comp.os.linux.development.apps)
  • Re: Why do folks implement statically typed languages?
    ... The languages discussed are extremes. ... It allows the compiler to prove that your data-manipulations are ... an IDE for a dynamically-typed language can ... to IDEs in dynamically-typed languages. ...
    (comp.lang.scheme)
  • Re: OO compilers and efficiency
    ... > will be difficult for a compiler to do a good job of spotting when the OO ... "simpler" languages, ... I agree that Java ... (including adding lexical closures) ...
    (comp.programming)
  • Re: Delphi 2008 native?
    ... That's a function of the particular compiler you use. ... Once upon a time there were a number of languages you could use to write ... Very impressive I'm sure, all that hardware grunt. ... but society places value on humans remaining in touch with reality. ...
    (borland.public.delphi.non-technical)
  • Re: Why is C good??? any experts?
    ... it to maintain someone else's code is a completely different matter. ... > hodge-podge of exported subroutines and messy global variables. ... Compilers and, to a lesser extent, languages ... For example, to compute any algebraic expression, a compiler will ...
    (comp.lang.c)