Subscribe to Windows IT Pro
May 16, 2001 12:00 AM

Effect of Comments on Performance

Windows IT Pro
InstantDoc ID #20773
Rating: (0)

I want to put comments in my scripts, but I've heard that comments slow script performance. Is this true, and if so, how can I get around this problem?

A script line that consists of only the Rem command does have some processing overhead. A line that also contains a comment, such as

REM Here is a comment

has additional overhead. The overhead for Rem comments is very small in the average script and should be a consideration only inside loops or in scripts that other scripts frequently call. To get a feel for the amount of overhead Rem comment lines add to a script, write a script with 100 lines of comments and run it by using the TimeThis utility in the Microsoft Windows 2000 Server Resource Kit or the Microsoft Windows NT Server 4.0 Resource Kit.

You can greatly reduce the overhead if you precede a comment with two colons (::) instead of Rem. For a large block of comments, such as author and other header information, use a Goto command at the beginning of the comments and a label at the end, as in the following script:

GOTO :Endcomments
:: Put comments here
:: More comments here
:: More comments here
:Endcomments 

Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.