Created
October 24, 2024 22:36
-
-
Save s-h-a-d-o-w/b015512ef2b098234c65a006117418f7 to your computer and use it in GitHub Desktop.
Measure execution time for a command, like `time` on Linux.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal | |
for /f "tokens=1-4 delims=:.," %%a in ("%time%") do ( | |
set /a "start=((((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100)" | |
) | |
cmd /c %* | |
for /f "tokens=1-4 delims=:.," %%a in ("%time%") do ( | |
set /a "end=((((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100)" | |
) | |
set /a duration=%end%-%start% | |
set /a seconds=%duration% / 100 | |
set /a centi=%duration% %% 100 | |
if %centi% lss 10 set centi=0%centi% | |
echo ================================= | |
echo Execution Time: %seconds%.%centi% seconds | |
endlocal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment