Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I cant stand REM in batch files because it easier to type :: and it's a whole lot easier to read.
To skip a line (as between paragraphs or commands or sections) I remember reading somewhere long ago that the OS processes lines faster if you use :: or REM rather than just a totally blank line.
Is this true? If so, why?

like you will see any difference .. maybe if you got 2000 rem statements in a single batchfile ...
I guess we are talinkg bout thousands of a second here

I tested it, and it's true! I had never thought about it. This was the script I used to test it:
@echo off
if "%1"=="GoTo:" %1%2
echo.EXIT|%comspec%/k prompt $T$_|FIND ":"
for %%? in (0 1 2 3 4 5 6 7 8 9) do call %0 GoTo: #2 %%?
echo.EXIT|%comspec%/k prompt $T$_|FIND ":"
goto eof
:#2
for %%? in (0 1 2 3 4 5 6 7 8 9) do call %0 GoTo: #3 %3%%?
goto eof
:#3
for %%? in (0 1 2 3 4 5 6 7 8 9) do call %0 GoTo: #4 %3%%?
goto eof
:#4
:eofPut between ':#4' and ':eof' 10 blank lines, run the script, than change those blank lines for 10 lines with "::" and run it again. The second run will be faster! (the script outputs the runtime)
With 10 lines being tested, we actually have the prefix (:: or blank line) being read 10000 times in this script. These were the results, dividing the total runtime difference by the times the prefix was read:
[::] X [blank line] - 0.000031 s
[::] X [REM] - 0.000136 sAs you can see, not a big difference here, but the speed IS different:
speed: '::' > BLANK LINE > 'REM'
-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.br

BTW, I've tested that under Windows 98 second edition, and my computer is:
PROCESSOR:PIII-700Mhz RAM:128MBI have no idea why using "::" is faster than just a blank line.
-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.br

The reason why is that DOS still reads lines with REM in them, but :: is a "double label", which in DOS is invalid, and thus ignored.

That what chip said seems to be true. Look these two lines:
REM comment > string
:: comment > stringThe first line creates the zero-byte file named 'string', because of the ">" redirection. However, the second line doesn't do that.
But there's still something in my mind: the example is valid from inside a batch file and also at the command prompt. However, look the following example:
:: comment |
From the command prompt, such line returns "Bad sintax", but it doesn't from inside a batch file. Why?
Maybe DOS reads the double label and then ignore everything until the next line break or the next pipe.
-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.br

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |