Squashman wrote:WOW! Way to skew the results in your favor by adding an extra comment in there. One line of code isn't going to have another comment after that. Get real man!
I5 Quad Core with your extra comment.
Code: Select all
C:\Batch>comment_test.bat
16:42:55.60 - 16:42:57.59 elapsed 199 cs
16:42:57.59 - 16:42:59.97 elapsed 238 cs
16:42:59.98 - 16:43:02.16 elapsed 218 cs
199 is 17% more speed than 238
199 is 9% more speed than 218
Without the extra comment.
Code: Select all
C:\Batch>comment_test.bat
16:45:31.20 - 16:45:33.22 elapsed 202 cs
16:45:33.22 - 16:45:35.44 elapsed 222 cs
16:45:35.44 - 16:45:37.56 elapsed 212 cs
202 is 10% more speed than 222
202 is 5% more speed than 212
I could really care less about 2 tenths of a second over 100,000 iterations!!!!
Not too mention 99.9% I would say all my comments are outside my FOR commands.
My initial comments were about readability. Stringing together a bunch of commands with the ampersand makes code extremely unreadable. I can deal with no comments but I can't deal with that kind of unread-ability. Heck I can even deal with single character variables but when people starting using symbols that is just irritating. No offense Jeb, your code is still pretty readable because you do space things out. Granted it does help distinguish between environmental variables and tokens.
Really, your example is relative to what you are doing so this really isn't a good example of performance.
You're cheating. You are mixing what I'm saying. I responded to the "quote" "partially" of foxidrive.
But I will say the same. In another case, I would not have responded.
1) You are attentive to the fact that I'm cheating but you do not realize that the code I'm measuring is without FOR. FOR The only serves to better measure.
2) Also I put two comments just because I want to comment WELL on my code. Or your.
The comment after or before the command not change the result!
3) In addition, we are measuring not only the comments. But the variables as you pointed out yourself. So if you do the calculations (this time do not cheat) you see that it goes up!
It 'obvious that depends on the code you're running. We are talking in general with particular examples.
I do not like to be misunderstood.
Code: Select all
0:29:49,38 - 0:29:52,77 elapsed 339 cs
0:29:52,77 - 0:29:58,89 elapsed 612 cs
0:29:58,91 - 0:30:04,82 elapsed 591 cs
339 is 45% more speed than 612
339 is 43% more speed than 591
Code: Select all
@echo off & setlocal EnableDelayedExpansion
rem Reference test
set t0=%time%
For /L %%i in (1,1,100000) do (
set /a $=$+1
)
call :difftime "%t0%" "%time%" t1
rem ::::::::::::::::::::::::::::::::::::::::
set t0=%time%
For /L %%i in (1,1,100000) do (
rem this is a comment
set /a Variable_name=variable_name+1
)
call :difftime "%t0%" "%time%" t2
rem ::::::::::::::::::::::::::::::::::::::::
rem the "rem" if faster then rem<SPACE>
set t0=%time%
For /L %%i in (1,1,100000) do (
rem
set /a Variable_name=Variable_name+1
)
call :difftime "%t0%" "%time%" t3
rem ::::::::::::::::::::::::::::::::::::::::
echo(
rem calculate percent
set /a p1=100-t1*100/t2
echo %t1% is %p1%%% more speed than %t2%
set /a p1=100-t1*100/t3
echo %t1% is %p1%%% more speed than %t3%
exit /b
:difftime
setlocal
set t0=%~1
set t1=%~2
for /F "tokens=1-8 delims=:.," %%a in ("%t0: =0%:%t1: =0%") do set /a "a=(((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d, a+=(a>>31) & 8640000"
echo %t0% - %t1% elapsed %a% cs
endlocal & set %3=%a%
exit /b
@all
can you post your results?
with respect
einstein1969