From: michelotto@vaxfpd.pd.infn.it (Michele Michelotto)
Subject: Re: cpu time measurement on VMS
Reply-To: michelot@dxcern.cern.ch
Organization: CERN - European Laboratory for Particle Physics
Date: Thu, 21 Jan 1993 07:36:27 GMT


In article <1993Jan20.164619.8700@eecs.nwu.edu>, shil@eecs.nwu.edu (Lei Shi) writes:

|>   I am a new user of OpenVMS running on Alpha. I have a problem and I am asking
|>for your help.  I have a FORTRAN program. I compile and link it and use run 
|>command to run it.  My question is how I can measure the total CPU used by the 
|>execution of the program.  In UNIX, I can easily use time to do it.  
|>But how do I do it in VMS?  Can some one help me?  Thanks a lot. 
|>
Try this program that I found on Usenet some times ago.    M0ichele

Try the following command file - just use @TIME command.  (There will be the
usual problems with quoted arguments, since one level of quotation marks will
be stripped off.)

The command file actually displays all the statistics it can get its hands on.
Note that VMS only maintains the peak virtual size and peak working set values
from the time the process started, so unless this particular command increased
the values, there is no way to know what the peaks for the command were.

I make no claims about the quality of this code; it was something I through
together quickly at some point when I needed it.
							-- Jerry

$! TIME.COM
$! V2.0		Jerry Leichter
$!
$ on error then continue
$ assign/user SYS$COMMAND SYS$INPUT
$ start_dirio = f$getjpi("","DIRIO")
$ start_bufio = f$getjpi("","BUFIO")
$ start_faults = f$getjpi("","PAGEFLTS")
$ start_virtpeak = f$getjpi("","VIRTPEAK")
$ start_wspeak = f$getjpi("","WSPEAK")
$ start_dt = f$time()
$ start_cpu = f$getjpi("","CPUTIM")
$'p1' 'p2' 'p3' 'p4' 'p5' 'p6' 'p7' 'p8'
$ end_cpu = f$getjpi("","CPUTIM")
$ end_dt = f$time()
$ end_dirio = f$getjpi("","DIRIO")
$ end_bufio = f$getjpi("","BUFIO")
$ end_faults = f$getjpi("","PAGEFLTS")
$ end_virtpeak = f$getjpi("","VIRTPEAK")
$ end_wspeak = f$getjpi("","WSPEAK")
$ deas/user/all				!Clean up SYS$INPUT; bad method....
$ cpu = f$integer(end_cpu) - f$integer(start_cpu)
$ cpu_s = cpu/100
$ cpu_hu = cpu - 100*cpu_s
$ if cpu_hu .lt. 10 then cpu_hu = "0" + f$string(cpu_hu)
$ el_h = f$integer(f$cvtime(end_dt,"ABSOLUTE","HOUR"))			-
		- f$integer(f$cvtime(start_dt,"ABSOLUTE","HOUR"))
$ el_m = f$integer(f$cvtime(end_dt,"ABSOLUTE","MINUTE"))		-
		- f$integer(f$cvtime(start_dt,"ABSOLUTE","MINUTE"))
$ el_s = f$integer(f$cvtime(end_dt,"ABSOLUTE","SECOND"))		-
		- f$integer(f$cvtime(start_dt,"ABSOLUTE","SECOND"))
$ el_hu = f$integer(f$cvtime(end_dt,"ABSOLUTE","HUNDREDTH"))	-
		- f$integer(f$cvtime(start_dt,"ABSOLUTE","HUNDREDTH"))
$ if el_hu .lt. 0
$ then
$	el_s = el_s - 1
$	el_hu = el_hu + 100
$ endif
$ if el_s .lt. 0
$ then
$	el_m = el_m - 1
$	el_s = el_s + 60
$ endif
$ if el_m .lt. 0
$ then
$	el_h = el_h - 1
$	el_m = el_m + 60
$ endif
$ if el_h .lt. 0
$ then
$	write SYS$OUTPUT "Elapsed time crossed midnight:  "		-
		start_dt," - ",end_dt
$	el_h = 0
$ endif
$ dirio = f$integer(end_dirio) - f$integer(start_dirio)
$ bufio = f$integer(end_bufio) - f$integer(start_bufio)
$ faults = f$integer(end_faults) - f$integer(start_faults)
$ el = "''el_h':''el_m':''el_s'.''el_hu'"
$ cp = f$string(cpu_s) + "." + f$string(cpu_hu)
$ if start_virtpeak .lt. end_virtpeak
$ then
$	virtpeak = end_virtpeak
$ else
$	virtpeak = "could not be determined"
$ endif
$ if start_wspeak .lt. end_wspeak
$ then
$	wspeak = end_wspeak
$ else
$	wspeak = "could not be determined"
$ endif
$ write SYS$OUTPUT "Elapsed ",f$cvtime(el,"ABSOLUTE","TIME"),", CPU ",cp
$ write SYS$OUTPUT							-
	"Incremental DIRIO ''dirio', BUFIO ''bufio', Faults ''faults'"
$ write SYS$OUTPUT							-
	"Peak virtual size ",virtpeak,", working set ",wspeak




--
						Ciao, Michele
******************************************************************************
* Michele Michelotto, INFN Padova, Delphi group.                             *
* Internet: michelot@dxcern.cern.ch     BITNET: MICHELOTTO@IPDINFN           *
* Tel (+39).49.844347                   HEPNET: VAXFPD::MICHELOTTO           *
*                     "Ho bevuto CHE COSA ?"   (Socrate)                     *
******************************************************************************