Re: Using with
- From: "Larry Serflaten" <serflaten@xxxxxxxxxxxxxx>
- Date: Wed, 3 May 2006 18:07:32 -0500
"Michael C" <nospam@xxxxxxxxxx> wrote
I tried your code but I can see a few problems with it. When you do
"Test.Add 1" this is really "Me.Test.Add 1", although I'm not sure if it
compiles that way or not.
It is interesting that you would say something is wrong with the test, and
then try to change it around to favor your position. 'Test' was a private
module variable, not accessable from Me, so it could not possibly
be - Me.Test.Add 1.
It was a fair test, both routines use the exact same variable reference,
calling the exact same methods on the object, the exact same number of
times. Having you think the test is flawed is somewhat surprizing. What
was even more surprizing was that you would change the scoping level of
the reference and then call that a more accurate test.
The function should really be written as below to
make a fair comparison.
I don't think so. Both use the same variable reference, eg, from the
same level of scope. Your change alters the code in an unnatural way
(why use a local variable when the module variable is readily available)
and alters the scope of the reference, therefore biasing the results. Even
still, using your change, I again find using With to be the faster method.
The other problem was that it is calling relatively
labour intensive functions to measure what is a very small difference.
If you mean there is an abundant amount of variable usage in each
routine, that was by design. The idea was to test the speed of referencing
methods on that object, so providing a routine that does that abundantly
is prudent. If there was only one call in each routine, the time to call
and return from the function could easily be greater than the items under
test. Since there is some amount of non-determined (Visual Basic) code
running between the calls to the routine that very probably can vary
due to current system conditions, reducing the number of calls in
relation to the code under test is the advisable thing to do. Did you
notice that even when you reduce the textbox value to 1 (meaning only
one call was made to either routine), using With was the clear winner
even then?
Hence
the error in the tests was greater than the difference in the results.
The test was not flawed, and it showed a significant differance in favor
of using With. The significance was due, in part, by the many calls on
the object made within the routine, but that is the natural usage of the
the With structure. Making just one call on an object would not suggest
the use of With would be advantageous, but when many such calls are
needed, that is when With is suggested to be used:
"The With statement allows you to perform a series of statements on a
specified object..."
I also got quite different results by reversing the tests and by running dummy
tests before the tests.
Were you going to post those results? Why would positioning effect any
of the results?
Did you check the code I posted in the reply to Dave. It fairly conclusively
proved what I was trying to point out.
Funny you should ask that since you should have been the first one to
recognise the test format and methods are very similar to what you wrote.
It is as if I took your code and simply changed the tests a bit, which is
what I did.
But again, as I said, even with your changes, I found using With to be
the faster method, so at the least, your 'proof' is far from conclusive.
LFS
.
- Follow-Ups:
- Re: Using with
- From: Michael C
- Re: Using with
- References:
- Using with
- From: gary
- Re: Using with
- From: Michael C
- Re: Using with
- From: Rick Rothstein
- Re: Using with
- From: Michael C
- Re: Using with
- From: Ralph
- Re: Using with
- From: Michael C
- Re: Using with
- From: Ralph
- Re: Using with
- From: J French
- Re: Using with
- From: Dave
- Re: Using with
- From: Michael C
- Re: Using with
- From: Dave
- Re: Using with
- From: Michael C
- Re: Using with
- From: Larry Serflaten
- Re: Using with
- From: Michael C
- Using with
- Prev by Date: Re: check user priviliges in VB
- Next by Date: Re: Admin privilege
- Previous by thread: Re: Using with
- Next by thread: Re: Using with
- Index(es):
Relevant Pages
|