Effect of Comments on Performance

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
Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.