home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / arexx / timeit.lha / timeit.rexx next >
Encoding:
OS/2 REXX Batch file  |  1991-10-13  |  1.1 KB  |  44 lines

  1. /*
  2. **  Find out how long something takes...
  3. **
  4. */
  5.  
  6.     parse arg cmd
  7.  
  8.     file = stdout
  9.     writeln( file, '' )
  10.     writeln( file, '**  Timing, starting at' date( s ) time( ) )
  11.     writeln( file, '' )
  12.     writeln( file, '     /~~~' cmd )
  13.     writeln( file, '' )
  14.  
  15.     begin_date = date( i )
  16.     begin_time = time( s )
  17.     address command cmd
  18.     end_date = date( i )
  19.     end_time = time( s )
  20.  
  21.  
  22.     run_seconds = end_time - begin_time
  23.     run_days    = end_date - begin_date
  24.  
  25.     run_hours   = run_seconds % 3600
  26.     run_seconds = run_seconds // 3600
  27.     run_minutes = run_seconds % 60
  28.     run_seconds = run_seconds // 60
  29.  
  30.     if length( run_days ) < 2 then run_days = right( run_days, 4 )
  31.     run_hours   = right( run_hours,   2, 0 )
  32.     run_minutes = right( run_minutes, 2, 0 )
  33.     run_seconds = right( run_seconds, 2, 0 )
  34.  
  35.     writeln( file, '' )
  36.     writeln( file, '     \___' cmd )
  37.     writeln( file, '' )
  38.     writeln( file, '    days hh:mm:ss' )
  39.     writeln( file, '    'run_days run_hours':'run_minutes':'run_seconds )
  40.     writeln( file, '' )
  41.     writeln( file, '---tear line!' )
  42.     writeln( file, '' )
  43.  
  44.