MSFN Forum: Code Repository - MSFN Forum

Jump to content


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Code Repository Code for all your needs Rate Topic: -----

#21 User is offline   FixitUP 

  • Newbie
  • Group: Banned
  • Posts: 47
  • Joined: 17-November 12
  • OS:XP Pro x86
  • Country: Country Flag

Posted 16 January 2013 - 02:37 PM

Batch file for timing scripts, etc.

:: HowLong.bat Timer for execution time for scripts, bat files, etc.
:: Wednesday, January 16, 2013 mousio,Magnum,
:: ** See notes within the script
::
call :StartTimer
::
:: Add what you want to time here
::

@echo off
setlocal disableDelayedExpansion
set "searchRoot=."
:: Set your file search pattern here
set "fileMask=s*.bat"

set "prior=noMatch"
for /f "tokens=1,2 delims=?" %%A in (
'(for /r "%searchRoot%" %%F in ("%fileMask%"^) do @echo %%~zF:%%~nxF?%%~fF^)^|sort'
) do (
set "current=%%A"
setlocal enableDelayedExpansion
if !prior! equ !current! (
if defined priorFile (
echo(
echo !priorFile!
)
endlocal
echo %%B
set "priorFile="
) else (
endlocal
set "prior=%%A"
set "priorFile=%%B"
)
)

call :StopTimer
call :DisplayTimerResult
pause
goto :EOF

:StartTimer
:: Store start time
set StartTIME=%TIME%
for /f "usebackq tokens=1-4 delims=:., " %%f in (`echo %StartTIME: =0%`) do set /a Start100S=1%%f*360000+1%%g*6000+1%%h*100+1%%i-36610100
goto :EOF

:StopTimer
:: Get the end time
set StopTIME=%TIME%
for /f "usebackq tokens=1-4 delims=:., " %%f in (`echo %StopTIME: =0%`) do set /a Stop100S=1%%f*360000+1%%g*6000+1%%h*100+1%%i-36610100
:: Test midnight rollover. If so, add 1 day=8640000 1/100ths secs
if %Stop100S% LSS %Start100S% set /a Stop100S+=8640000
set /a TookTime=%Stop100S%-%Start100S%
set TookTimePadded=0%TookTime%
goto :EOF

:DisplayTimerResult
:: Show timer start/stop/delta
echo Started: %StartTime%
echo Stopped: %StopTime%
echo Elapsed: %TookTime:~0,-2%.%TookTimePadded:~-2% seconds
goto :EOF


Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy