If you do not mind that this will give wrong results if the first time is before midnight, and the second time is after (the next, or a subsequent!) midnight, then this code takes the hours, minutes, seconds, and hundredths of a second in the %time% variable and converts to a figure in milliseconds, and it takes much less than 2 seconds! I would not trust it to beyond around 50 msec though.
@echo off
set ntime=%time%
REM slice up %time%
REM presumes 24 hr clock hh:mm:ss.nn
REM nn=1/100ths of seconds
set hh=%ntime:~0,2%
set mm=%ntime:~3,2%
set ss=%ntime:~6,2%
set cs=%ntime:~9,2%
REM remove any leading zeroes because set /a
REM treats them as indicating octal values
REM and barfs at 08 and 09, understandably!
REM also remove leading space if hour < 10
if "%hh:~0,1%"==" " set hh=%hh:~1,1%
if "%mm:~0,1%"=="0" set mm=%mm:~1,1%
if "%ss:~0,1%"=="0" set ss=%ss:~1,1%
if "%cs:~0,1%"=="0" set cs=%cs:~1,1%
REM now they are all valid integer values, do the arithmetic
set /a msec=3600000*%hh%+60000*%mm%+1000*%ss%+10*%cs%
echo %msec%
say you called it mtime.bat and stored it somewhere on your PATH, you could use it like this
With just that "REM code to be timed" line I am mostly seeing values between 100 & 200 msec with a few as low as 70 or as high as 230.
@echo off
for /f %%T in ('mtime.bat') do set time1=%%T
REM code to be timed
for /f %%T in ('mtime.bat') do set time2=%%T
set /a elapsed=%time2%-%time1%
echo elapsed %elapsed% milliseconds