Created
November 29, 2016 01:21
-
-
Save sergeevabc/2a33504b881f4f292f94e1579d8f4f2b to your computer and use it in GitHub Desktop.
Measure execution time
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 | |
:: Get start timestamp | |
set _time=%time% | |
set _hours=100%_time:~0,2%%%100 | |
set _min=100%_time:~3,2%%%100 | |
set _sec=100%_time:~6,2%%%100 | |
set _cs=%_time:~9,2% | |
set /a _started=_hours*60*60*100+_min*60*100+_sec*100+_cs | |
:: Runs your command | |
cmd /c %* | |
:: Get difference in cSeconds | |
set _time=%time% | |
set _hours=100%_time:~0,2%%%100 | |
set _min=100%_time:~3,2%%%100 | |
set _sec=100%_time:~6,2%%%100 | |
set _cs=%_time:~9,2% | |
set /a _duration=_hours*60*60*100+_min*60*100+_sec*100+_cs-_started | |
:: Populate variables for rendering (100+ needed for padding) | |
set /a _hours=_duration/60/60/100 | |
set /a _min=100+_duration/60/100%%60 | |
set /a _sec=100+(_duration/100%%60%%60) | |
set /a _cs=100+_duration%%100 | |
echo. | |
echo Execution time: %_hours%:%_min:~-2%:%_sec:~-2%.%_cs:~-2% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment