Re: How to find the datatype of a variable?
- From: "Steve Gerrard" <mynamehere@xxxxxxxxxxx>
- Date: Mon, 26 Nov 2007 20:22:08 -0800
"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.
.
- Follow-Ups:
- Re: How to find the datatype of a variable?
- From: Robert Morley
- Re: How to find the datatype of a variable?
- References:
- Re: How to find the datatype of a variable?
- From: Mike Williams
- Re: How to find the datatype of a variable?
- From: Robert Morley
- Re: How to find the datatype of a variable?
- From: MikeD
- Re: How to find the datatype of a variable?
- From: Robert Morley
- Re: How to find the datatype of a variable?
- From: Robert Morley
- Re: How to find the datatype of a variable?
- Prev by Date: Re: I used to use VB but...
- Next by Date: Re: I used to use VB but...
- Previous by thread: Re: How to find the datatype of a variable?
- Next by thread: Re: How to find the datatype of a variable?
- Index(es):
Relevant Pages
|