Re: Can 'MInifying' vbscript provide performance gain?



Jason wrote;

Can removing all comments, blank lines, tabs etc from vbscript code
provide
any performance boost? We are looking to tweak any performance we can get
out
of our app, I know it's a bit extreme of a move but is it viable?

I have created a script to do this and it removes about 12mb from the file
system footprint. Do you think that when the scripts are interpretted this
could save some time?


In principal, removing white space should make the script run faster, but I
doubt you could measure the difference. In my experience, the biggest hit to
performance is the number of binding operations to objects that are not
local. Binding to local objects, like wshShell or the Dictionary object, is
fast, but binding to objects in Active Directory is slow. That's why
retrieving information from AD with ADO is so efficient. You bind to a few
local objects, then retrieve lots of values in one operation. Doing the same
thing by binding to each AD object would be much slower.

I have found that using "Option Explicit" and declaring all variables seems
to improve performance. My theory is that the interpreter no longer needs to
guess about your intentions, or perhaps it saves preprocessing. This despite
the fact that the file becomes larger.

I always use lots of white space and comments. I indent structures like
If/End If, For Each/Next, and Do Until/Loop. I use long descriptive variable
names. I never use With blocks. I try to always make things explicit and not
assume defaults. I use Option Explicit and declare all variables. Sometimes
others rewrite my code to be much smaller, requiring much less typing. My
chatty version is invariably faster. My motto is that anything that saves
the coder typing is generally not a good idea. All of this is in addition to
the "chatty" code being much easier to understand, troubleshoot, and modify.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--


.



Relevant Pages

  • Re: Err.Description does not contain the full text of the error me
    ... The directive "Option explicit" is sufficient ... It does this by using Exec to run each script and ... Chasing undeclared variables in a VB Script file appears ... just an oversight by the programmer that makes ...
    (microsoft.public.scripting.vbscript)
  • Re: Err.Description does not contain the full text of the error me
    ... The directive "Option explicit" is sufficient ... We have a large set of libraries we have written for use with QTP (an ... compilation errors. ... It does this by using Exec to run each script and ...
    (microsoft.public.scripting.vbscript)
  • Re: Function redefinition
    ... > It seems to me that Option Explicit affects only the variable definitions. ... This seems to be an intentional design aspect of the script. ...
    (microsoft.public.scripting.vbscript)
  • Re: IDE or Editor for VBS?
    ... I didn't know that MS script editor existed before, ... - How do I use early binding or late binding to call intellisense? ... > I don't know that CAD program, ... > Using Excel-VBE, I can edit the script controling Lotus Notes, ...
    (microsoft.public.scripting.vbscript)
  • Re: rename a local group in windows 2003
    ... I tried to rename several local groups using the MoveHere method ... Didn't matter if I ran the script on the ... WinNT provider only rename domain groups, ... All AD and local objects are renamed using the MoveHere method of the ...
    (microsoft.public.windows.server.scripting)