Desired number of spaces - optimizing the code?
Posted: 11 Dec 2014 06:19
Hi all!
I have a subprogram to make a variable with desired number of spaces:
This subprogram runs fast enough if the file size (of .cmd) is relatively small. If I add some few thousands of lines it goes very slow.
Less than a second if this is very short program. I added 60000 records (does not matter if they are at the beginning of a file or at the end) execution time increases to 24 seconds.
Any ideas? (I prefer not to use delayed expansion and such commands).
Would it run faster if it would be a FOR /L loop (I cannot make it to work)?
Thanks.
Saso
I have a subprogram to make a variable with desired number of spaces:
Code: Select all
@echo off
echo %TIME%
call :makespaces 100
echo %TIME%
goto :EOF
:makespaces
set spaces=&rem
set par1=%1&rem
set /a cntspaces=0
:spacesback
set spaces= %spaces%
set /a cntspaces+=1
if %cntspaces% LSS %par1% goto :spacesback
goto :EOF
This subprogram runs fast enough if the file size (of .cmd) is relatively small. If I add some few thousands of lines it goes very slow.
Less than a second if this is very short program. I added 60000 records (does not matter if they are at the beginning of a file or at the end) execution time increases to 24 seconds.
Any ideas? (I prefer not to use delayed expansion and such commands).
Would it run faster if it would be a FOR /L loop (I cannot make it to work)?
Thanks.
Saso