Author Topic: Timing for your batch files  (Read 52 times)

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 895
    • View Profile
Timing for your batch files
« on: June 09, 2021, 11:07:27 AM »
Recompiling BCX and other projects can sometimes take a long time to complete.
And where BCX translates files really quickly, the various C\C++ compilers require a lot
more time to do their jobs.

Today I came up with a timing method for batch files that I think is pretty useful.  Now,
this method is not going to give you high resolution timing - in fact the closest you'll get
is about 1 second accuracy but that's good enough when you're compiling phase takes
10, 20, 30 seconds or longer.

Step 1) Compile a 1 line BCX program:   END = TIMER   
             I named my program "TIMER.BAS"  and I keep TIMER.EXE in my system PATH
            where all my batch files can find it.

Step 2) Add these lines to your batch file BEFORE the process(es) that you want to time:

Code: [Select]

TIMER.exe
SET /A a = %ERRORLEVEL%



Step 3) Add these lines to your batch file AFTER  the process(es) that you want to time:

Code: [Select]

TIMER.exe
SET /A b = %ERRORLEVEL%
SET /A c = %b% - %a%
ECHO Compile took %c% seconds


You can change the names of the batch variable names, if you want to,
and of course, you can change the completion message to suit your taste.

It works for me ... it should work for you too.   :)
 
« Last Edit: June 09, 2021, 06:09:22 PM by MrBcx »

Robert

  • Hero Member
  • *****
  • Posts: 664
    • View Profile
Re: Timing for your batch files
« Reply #1 on: June 10, 2021, 10:27:11 PM »
Thank you for this, MrBCX. A nifty trick. With his keen interest in batch files, Joe should like this item.