Re: How to find the datatype of a variable?

Tech-Archive recommends: Speed Up your PC by fixing your registry




"Robert Morley" <rmorley@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:%23InsAzHMIHA.4272@xxxxxxxxxxxxxxxxxxxxxxx
Well, I just tested it using a fairly primitive test, and got some
not-too-surprising results.

In the IDE, the test below took MUCH longer, and came out with roughly the
same results in each variation of the test; in a compiled EXE with all
optimizations turned on and "Favor Pentium Pro" enabled (if that makes any
difference at this point), the first test came out noticeably slower than the
others, though (2.5 s on average vs. 2.0 s for the other two). This was done
on a Core2 Duo @ 3.0 GHz.

The results would seem to confirm that the simple "a = 1" assignment is
implicitly converting to an integer, then up to a long. When I changed it to
"a = 65536", the results of all three tests were identical.


Well, I got some interesting results with your code. :)

First, I had to add
mlngDummy = 0
before each loop, because it was unhappy being run up to 3 billion.

Second, I got this (or similar in range of 2.5 to 2.6), with only standard fast
code optimization:
2.578
2.578
2.656

Third, the Favor Pentium Pro option slowed it down to a 3 - 3.6 range. I believe
the docs state that this option produces code that is slower when run on non
Pentium Pro chips.

Fourth, using 65536 (and avoiding overflow by just adding 1 to mlngDummy) made
no significant difference.

Fifth (and this is the good one), the optimization "Remove Integer Overflow
Checks" slowed it down quite a bit:
5.297
5.375
5.250

In conclusion, on my machine (P4, 2.4 GHz), 1 or 1& or CLng(1) give essentially
the same result, and the "optimization" of "Remove Integer Overflow Checks" is
not an optimization at all in some cases. I would love to know if that last one
is reproducible by others.



.



Relevant Pages

  • Re: Speed quirk: redundant line gives six-fold speedup
    ... Any possible explanations? ... If, is there some way to force the optimization, so that I can ... when you ran the first test, but not the second test, resulting in the ... the speed change had nothing to do with ...
    (comp.lang.python)
  • Re: How to find the datatype of a variable?
    ... I'd noticed the mlngDummy issue (even more obvious when running Command1_Click multiple times), but didn't worry about it because I figured it was irrelevant to the code with the overflow checks turned off...little did I know! ... Interestingly, this was only the case when remove integer overflow checking was checked; ... Fifth, the optimization "Remove Integer Overflow Checks" slowed it down quite a bit: ...
    (microsoft.public.vb.general.discussion)
  • Re: Low level folks: Beat this!
    ... >I got an integer overflow in your program with checks on. ... >optimization on. ... your first and third algorithms gave incorrect results when I ran ... them for 8 queens. ...
    (comp.lang.pascal.delphi.misc)