Код:
@ECHO OFF
REM Var
SET var=1234567890абвгдежзийabcdefghij#_
CALL :_Timer
SET nn=0
:Loop
SET /a nn+=1
REM ------------------------------ 2х строчный вариант ------------------------------
<NUL SET /p "ECHO=%var%" > "qwe.txt"
FOR /F %%f IN ("qwe.txt") DO ( SET /a "zoo=%%~zf" )
REM DEL "qwe.txt" /f /q
REM ---------------------------------------------------------------------------------
IF "%nn%"=="1000" ( GOTO :EndLoop )
GOTO :Loop
:EndLoop
SET /a otimer=%timer%
CALL :_Timer
SET /a res=%timer% -%otimer%
ECHO %res% ms
PAUSE >NUL
EXIT
:_Timer
FOR /F "usebackq tokens=*" %%f IN (`^<NUL TIME ^| FIND /i "’ҐЄг饥 ўаҐ¬п:"`) DO ( SET "timer=%%f" )
SET timer=%timer:~-11%
SET /a timer=%timer:~0,2% *3600000 +%timer:~3,2% *60000 +%timer:~6,2% *1000 +%timer:~-2% *10
GOTO :EOF
Время выполнения: 4980 ms
С раскоментированной строкой «DEL "qwe.txt" /f /q»: 5840 ms
Код:
@ECHO OFF
REM Var
SET var=1234567890абвгдежзийabcdefghij#_
CALL :_Timer
SET nn=0
:Loop
SET /a nn+=1
REM ------------------------------ 6ти строчный вариант -----------------------------
SET $StringLen=0
:StrLoop
SET /a $StringLen+=1
CALL SET $StringChr=%%var:~%$StringLen%%%
IF "%$StringChr%"=="" ( GOTO :EndStrLoop )
GOTO :StrLoop
:EndStrLoop
REM ---------------------------------------------------------------------------------
IF "%nn%"=="1000" ( GOTO :EndLoop )
GOTO :Loop
:EndLoop
SET /a otimer=%timer%
CALL :_Timer
SET /a res=%timer% -%otimer%
ECHO %res% ms
PAUSE >NUL
EXIT
:_Timer
FOR /F "usebackq tokens=*" %%f IN (`^<NUL TIME ^| FIND /i "’ҐЄг饥 ўаҐ¬п:"`) DO ( SET "timer=%%f" )
SET timer=%timer:~-11%
SET /a timer=%timer:~0,2% *3600000 +%timer:~3,2% *60000 +%timer:~6,2% *1000 +%timer:~-2% *10
GOTO :EOF
Время выполнения: 112270 ms (~ в 20 раз дольше при 32х символьной строке)