forked from utwente-fmt/vercors
-
Notifications
You must be signed in to change notification settings - Fork 0
/
timecmd.bat
32 lines (27 loc) · 1.07 KB
/
timecmd.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@echo off
@setlocal
chcp 65001
set start=%time%
echo Started at %time%
:: Runs your command
cmd /c %*
set end=%time%
set options="tokens=1-4 delims=:.,"
for /f %options% %%a in ("%start%") do set start_h=%%a&set /a start_m=100%%b %% 100&set /a start_s=100%%c %% 100&set /a start_ms=100%%d %% 100
for /f %options% %%a in ("%end%") do set end_h=%%a&set /a end_m=100%%b %% 100&set /a end_s=100%%c %% 100&set /a end_ms=100%%d %% 100
set /a hours=%end_h%-%start_h%
set /a mins=%end_m%-%start_m%
set /a secs=%end_s%-%start_s%
set /a ms=%end_ms%-%start_ms%
if %ms% lss 0 set /a secs = %secs% - 1 & set /a ms = 100%ms%
if %secs% lss 0 set /a mins = %mins% - 1 & set /a secs = 60%secs%
if %mins% lss 0 set /a hours = %hours% - 1 & set /a mins = 60%mins%
if %hours% lss 0 set /a hours = 24%hours%
set /a totalsecs = %hours%*3600 + %mins%*60 + %secs%
if 1%ms% lss 100 set ms=0%ms%
if 1%secs% lss 100 set secs=0%secs%
if 1%mins% lss 100 set mins=0%mins%
if 1%hours% lss 100 set hours=0%hours%
:: Mission accomplished
echo Verification took %hours%:%mins%:%secs%.%ms% (%totalsecs%.%ms%s total)
echo