home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / vms / 21604 < prev    next >
Encoding:
Text File  |  1993-01-21  |  2.9 KB  |  70 lines

  1. Newsgroups: comp.os.vms
  2. Path: sparky!uunet!spool.mu.edu!uwm.edu!linac!unixhub!slacvx.slac.stanford.edu!fairfield
  3. From: fairfield@slacvx.slac.stanford.edu
  4. Subject: Re: Anybody have time arithmetic routines?
  5. Message-ID: <1993Jan21.002747.1@slacvx.slac.stanford.edu>
  6. Lines: 58
  7. Sender: news@unixhub.SLAC.Stanford.EDU
  8. Organization: Stanford Linear Accelerator Center
  9. References: <1993Jan21.020035.18787@slcs.slb.com>
  10. Date: Thu, 21 Jan 1993 08:27:47 GMT
  11.  
  12. In article <1993Jan21.020035.18787@slcs.slb.com>, brydon@asl.slb.com (Harvey Brydon (918)250-4312) writes:
  13. > I have to do some reporting on some timing tests and have a need to calculate
  14. > elapsed times for a number of values.  Is there a way to calculate this in a
  15. > simple fashion (DCL preferred, Fortran otherwise)?  I'll be parsing the
  16. > timestamps from an RMS file with DCL.  Before I get a league of answers about
  17. > calculating delta time from 'now', let me make it clear I need to calculate
  18. > this from two arbitrary timestamps.  eg:
  19. > $ t1 = "20-JAN-1993 08:07:09.03"
  20. > $ t2 = "20-JAN-1993 10:22:13.44"
  21. > $! (magic dcl here)
  22. > $ show sym diff  ==> "0 02:15:04.41"
  23.  
  24. [etc...]
  25.  
  26.     There was a thread on a related topic going on just a week ago
  27. under the subject ` Implimenting  "TOMMORROW + 1:00:00" ' (that's
  28. pretty close anyway).  Check there, but also see below...
  29.  
  30. > Anybody have any tricks for this or is it just a matter of brute force
  31. > parsing, adding and carrying?
  32.  
  33.     I'm sure it _can_ be done in DCL, but I'd suggest Fortran instead:
  34. no need to parse, add or carry ;-)  Here's an outline:
  35.  
  36.     1) Use LIB$GET_SYMBOL to read in your two (or more) DCL time
  37.        symbols, t1 and t2.
  38.  
  39.     2) Use SYS$BINTIM to convert each to 64-bit internal time (quadword,
  40.        just use a 2-long integer*4 array).
  41.  
  42.     3) Use LIB$SUB_TIMES to get the 64-bit delta time between the t1
  43.        and t2 quadwords (there's also a LIB$ADD_TIMES for doing your
  44.        delta time additions).
  45.  
  46.     4) Use SYS$ASCTIM to convert the time quadword result back
  47.        to an ascii time string.  I think there are flags to
  48.        control whether you get an "absolute" or a "delta" time
  49.        back...check the help/docs, it could be automatic.
  50.  
  51.     5) Use LIB$SET_SYMBOL to define a DCL symbol containing the
  52.        resultant delta ascii time string.
  53.  
  54.     There are no item lists involved so about half a page of Fortran
  55. ought to do it (OK, OK!  A page and a half with proper return status
  56. checking and comments :-).
  57.  
  58.     You'll suffer image activation time overhead compared to doing 
  59. it all in DCL, but I'll bet it's faster just the same!  Certainly
  60. simpler to code, more flexible, and less error-prone.
  61.  
  62.     -Ken
  63. -- 
  64.  Dr. Kenneth H. Fairfield    |  Internet: Fairfield@Slac.Stanford.Edu
  65.  SLAC, P.O.Box 4349, MS 98   |  DECnet:   45537::FAIRFIELD (45537=SLACVX)
  66.  Stanford, CA   94309        |  BITNET    Fairfield@Slacvx
  67.  ----------------------------------------------------------------------------
  68.  These opinions are mine, not SLAC's, Stanford's, nor the DOE's...
  69.