Skip to content

Instantly share code, notes, and snippets.

@s-h-a-d-o-w
Created October 24, 2024 22:36
Show Gist options
  • Save s-h-a-d-o-w/b015512ef2b098234c65a006117418f7 to your computer and use it in GitHub Desktop.
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.
@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