With Clause

  • Thread starter Thread starter Chris, Master of All Things Insignificant
  • Start date Start date
Jay B. Harlow said:
Cor & David,
Interesting, if you compile my "benchmark" in the release build & run it
outside the IDE (such as from a command prompt). The times are all nearly
identical. Which IMHO makes With purely personal prefence (no hurt & no
help, use it if it helps you read the code).

Also, if you USE that 'do nothing' code.

A major question I would have is:

How much optimization is being done by the JIT compiler, in that sort of
'minimal' code? Did the JIT compiler resolve the references (providing inline
code perhaps), or are you actually resolving them with your code?
(Yes, the JIT compiler does its own optimizations...)

???
LFS
 
Jay B. Harlow said:
I take it you worry more about performant code then "correct" code?
By "correct" code I mean a sold OO design which allows easy of maintainability
& readibility among other things...

When performance differences are negligible, I tend to be a minimalist. I want
to use only the code necessary to do the job.
OO design,
maintainability, readability are IMHO more important driving forces...

I'd order them differently; Readability, conciseness, and then OO design.

If the code is easily read, it will 'generally' also be easy to maintain, and,
OOA is not as important to me as keeping code size down to more managable
sizes. I really liked 'component based' programming (AKA: COM) and to
the effect that objects also include encapsulation, I like those as well.

:-)
LFS
 
Larry,
A major question I would have is:

How much optimization is being done by the JIT compiler, in that sort of
'minimal' code?
Isn't this a Moot or Rhetorical question? If all three perform the same in
Release builds, and differently in Debug, would that not suggest the JIT is
doing some serious optimization?


As you know Debug builds & running under the IDE disable most if not all JIT
optimizations.

(Yes, the JIT compiler does its own optimizations...)
I hope you are not impling I do not know that, as that is why I specifically
stated, run the release build outside the IDE!

Hope this helps
Jay
 
Jay B. Harlow said:
David,
Which I hope you will agree is what I stated in my reply to Cor.

I also hope you will agree, even under VB5 & VB6 in your simply example
there would be no real performance benefit.

Absolutely. VBScript performance used to really matter because of Microsoft
Access and then because of ASP. Only then was WITH even on the performance
radar.

And I believe that in VBScript
with obj
.foo
.foo
end with

was faster than
obj.foo
obj.foo

because the runtime type of obj only had to be discovered once.

David
 
Isn't this a Moot or Rhetorical question? If all three perform the same in
Release builds, and differently in Debug, would that not suggest the JIT is
doing some serious optimization?

Quite so, which is why I wondered how you could conclude that With usage was
purely personal preference related, opposed to deducing that perhaps, the code
used was not diverse enough to show where With is a benefit:

Perhaps using With on an external object, where JIT optimizations would not
apply, might be a better example for profiling?

I hope you are not impling I do not know that

No, that was a parenthetical inclusion for everyone else who may be
reading the thread....

LFS
 
David,
because the runtime type of obj only had to be discovered once.
I would hope it does, Its been too long since I used VBScript...
VBScript performance used to really matter because of Microsoft Access and
then because of ASP.
Microsoft Access uses VBA not VBScript. Access started out with Access Basic

ASP & Outlook use VBScript.

Thanks for the info
Jay
 
Larry,
Perhaps using With on an external object, where JIT optimizations would
not
apply, might be a better example for profiling?
I'm sorry I believe you missed the reason for the sample in an earlier post
of mine:

<quote>
Of course the above test was designed to prove the point that With will help
performance with some code. In the original questions case I think its
largely a moot point, there With is "purely" personal preference.
</quote>

The sample I did intentionally shows that using With is a personal
preference, it was to disprove the statement.

<quote>
Your notion that WITH helps with performance by reducting object
resolutions is obsolete.
</quote>

As we all know a number of benchmarks are generally designed to prove a
point. Personally you need to profile actual specific code (not create a
"better example") to decide if the code fits or does not fit a routine.
(hint the 80/20 rule).

Hope this helps
Jay
 
Jay,

I tested it, outside the IDE and inside. Outside : inside the IDE is about
1:1,5 for all except the part without "with" which is inside the IDE 2 times
slower than the other ones.

After that you have explained what is this code beneath in your code, than I
thank you for supplying this test to us, now we can point next time to that
test when the question comes again.
Return

Application.EnableVisualStyles()
Application.DoEvents()
Application.Run(New MainForm)

Cor
 
Back
Top