Batch now displays call execution time #7

Merged
Segcolt merged 1 commits from dnk-general into master 2024-10-15 12:32:11 -03:00

32
run.bat
View File

@ -25,7 +25,12 @@ for %%g in (%TEST_FOLDER%\*) do (
for /f "delims=" %%h in ("!testname!") do set optimal=!solutions[%%h]!
echo Arquivo de teste: %%g
set start_t=!TIME!
for /f "tokens=4" %%h in ('!EXEC! !ARGS! ^< %%g') do set res=%%h
set end_t=!TIME!
call :difftime !start_t! !end_t! difference
echo Resultado do programa: !res!
if defined optimal (
echo Resultado ótimo: !optimal!
@ -36,6 +41,7 @@ for %%g in (%TEST_FOLDER%\*) do (
echo Diferença de !diff!
)
)
echo Tempo de execução: !difference! segundos
)
endlocal
@ -43,4 +49,30 @@ set EXEC=
set TEST_FOLDER=
set SOLUTIONS_FILE=
set ARGS=
goto :eof
rem Function that gets the difference between two %TIME% variables, expects args= start(VAL), end(VAL), ret(VARNAME)
rem This function assumes that the difference in time is LESS THAN 24 HOURS; If the difference is larger, return is incorrect
:difftime
setlocal
for /f "tokens=1-3 delims=:" %%a in ("%~1") do (
set /a start_h= ^(1%%a-100^) * 3600
set /a start_m= ^(1%%b-100^) * 60
set /a start_s= ^(1%%c-100^)
)
for /f "tokens=1-3 delims=:" %%a in ("%~3") do (
set /a end_h= ^(1%%a-100^) * 3600
set /a end_m= ^(1%%b-100^) * 60
set /a end_s= ^(1%%c-100^)
)
set /a start_i= %start_h% + %start_m% + %start_s%
set /a end_i= %end_h% + %end_m% + %end_s%
set /a diff_t= %end_i% - %start_i%
if diff_t LSS 0 set /a diff_t= %diff_t%+86400
endlocal & set %~5=%diff_t%
goto :eof