home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / vms / 21855 < prev    next >
Encoding:
Internet Message Format  |  1993-01-24  |  6.9 KB

  1. Path: sparky!uunet!elroy.jpl.nasa.gov!ames!agate!ucbvax!ACAD.DRAKE.EDU!SK0001
  2. From: SK0001@ACAD.DRAKE.EDU (Sal Kabalani)
  3. Newsgroups: comp.os.vms
  4. Subject: CPU Time measurement on VMS.
  5. Message-ID: <01GTTXFQMDQQ0006QT@ACAD.DRAKE.EDU>
  6. Date: 23 Jan 93 00:52:45 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Distribution: world
  9. Organization: The Internet
  10. Lines: 167
  11.  
  12. LS> Hi: 
  13. LS> 
  14. LS>    I am a new user of OpenVMS running on Alpha. I have a problem and I am 
  15. LS> asking for your help.  I have a FORTRAN program. I compile and link it and 
  16. LS> use run command to run it.  My question is how I can measure the total CPU 
  17. LS> used by the execution of the program.  In UNIX, I can easily use time to 
  18. LS> do it.  But how do I do it in VMS?  Can some one help me?  Thanks a lot. 
  19. LS> 
  20. LS>                     Your Sincerely,
  21. LS> 
  22. LS>                     Lei Shi
  23.  
  24. Hello Lei
  25.  
  26. The following is a fragment of code from a program I wrote a few months ago.
  27. The fragment reports CPU Time, Buffered I/O, Direct I/O and Page Faults used
  28. during program execution. The way the code works is simple: you collect this 
  29. information at the beginning of your program using sys$getjpi, then collect it 
  30. again at the end, then report the difference.
  31.  
  32. The code is written in VAX basic, but it shouldn't be too difficult to convert
  33. to FORTRAN. It was tested on a VAX 4600 running VMS 5.5-2. I do not have access
  34. to an OpenVMS machine.
  35.  
  36. Hope this helps.
  37.  
  38. .-Sal A Kabalani----------+--Internet: SK0001 @ Acad.Drake.Edu----------------.
  39. | Superv. of Operations   |     Phone: (515) 830-0436                         |
  40. | Data Systems Department | VoiceMail: (515) 830-1086    II  I\  II  .IIII    |
  41. | Iowa Network Services   |      Fax : (515) 830-0123    II  II\ II  III      |
  42. | 4201 Corporate Drive    | Centralized Equal Access     II  II \II    III    |
  43. | Des Moines, Iowa 50265  |         CIC 225              II  II  \I  IIII'    |
  44. `----------------------- Programmers Do It With a Byte -----------------------'
  45.  
  46.  
  47. !--------------------------------- Cut Here -----------------------------------!
  48. Option type = explicit     ! All Variables must be explicitly declared
  49.  
  50. Record Item_List_3         ! Item List Record for SYS$GETJPI
  51.     Variant
  52.     Case
  53.         Word Buff_Len
  54.         Word Code       
  55.         Long Buff_Add
  56.         Long Len_Add
  57.     case
  58.         Long terminator
  59.     end variant
  60. end Record
  61.  
  62. Common (JPI_Vars)       Long    BUFIO         ,&
  63.                                 DIRIO         ,&             
  64.                                 PAGEFLTS      ,&            
  65.                                 CPUTIM        ,&           
  66.                                 BEG_BUFIO     ,&              
  67.                                 BEG_DIRIO     ,&              
  68.                                 BEG_PAGEFLTS  ,&              
  69.                                 BEG_CPUTIM                   
  70.  
  71. External Long function          sys$getjpiw
  72.  
  73. %include "$BASDEF" %from %library  "SYS$LIBRARY:basic$starlet.tlb"  
  74. %Include "$JPIDEF" %from %Library  "Sys$LIbrary:BASIC$STARLET.TLB"   
  75.  
  76. External Long   Constant    SS$_Normal     ,&                  
  77.                             JPI$_BUFIO     ,&                 
  78.                             JPI$_CPUTIM    ,&                  
  79.                             JPI$_DIRIO     ,&                  
  80.                             JPI$_PAGEFLTS                    
  81.  
  82. Declare  Long               Sys_Status     
  83. Declare  Word               Length
  84. Declare  Real               Begin_CPUTIME
  85.  
  86.  
  87. Def String Convert_Time (Long My_Time)
  88.     !
  89.     ! Function to convert time from 100ths of seconds to the format hh:mm:ss.hh
  90.     !
  91.     Declare Real this_time, Hours, Minutes, Seconds
  92.     This_Time = My_Time
  93.     This_Time = This_Time / '100'L
  94.     Hours = Int (This_Time/'3600'L) 
  95.     This_Time = This_Time - (Hours*'3600'L)
  96.     Minutes = Int (This_Time/'60'L)
  97.     Seconds = This_Time - (Minutes*'60'L)
  98.     Convert_Time = Format$(Hours, "<0>#:") + Format$(Minutes,"<0>#:") + &
  99.                    Format$(Seconds, "<0>#.##") 
  100. End Def    
  101.  
  102. Get_Initial_Stats:
  103.     Declare Item_list_3 Begin_JPI_Item_list(4)
  104.  
  105.     Begin_JPI_Item_List(0)::Buff_Len  = 4%                       
  106.     Begin_JPI_Item_List(0)::Code      = Jpi$_BUFIO
  107.     Begin_JPI_Item_List(0)::Buff_Add  = Loc(BEG_BUFIO)     
  108.     Begin_JPI_Item_List(0)::Len_Add   = Loc(length)
  109.  
  110.     Begin_JPI_Item_List(1)::Buff_Len  = 4%                       
  111.     Begin_JPI_Item_List(1)::Code      = Jpi$_CPUTIM
  112.     Begin_JPI_Item_List(1)::Buff_Add  = Loc(BEG_CPUTIM)    
  113.     Begin_JPI_Item_List(1)::Len_Add  = Loc(length)
  114.  
  115.     Begin_JPI_Item_List(2)::Buff_Len  = 4%                       
  116.     Begin_JPI_Item_List(2)::Code      = Jpi$_DIRIO
  117.     Begin_JPI_Item_List(2)::Buff_Add  = Loc(BEG_DIRIO)     
  118.     Begin_JPI_Item_List(2)::Len_Add  = Loc(length)
  119.  
  120.     Begin_JPI_Item_List(3)::Buff_Len  = 4%                       
  121.     Begin_JPI_Item_List(3)::Code      = Jpi$_PAGEFLTS
  122.     Begin_JPI_Item_List(3)::Buff_Add  = Loc(BEG_PAGEFLTS)  
  123.     Begin_JPI_Item_List(3)::Len_Add   = Loc(length)
  124.  
  125.     Begin_JPI_Item_List(4)::terminator   = 0                     
  126.     
  127.     Sys_status = Sys$getjpiw (,,,Begin_JPI_Item_list() by REF,,,) 
  128.                      
  129.     Print "Initial Process Statistics:"
  130.     Print                                        
  131.     Print "      Page Faults:          ";format$(beg_pageflts,"#,###,###")
  132.     Print "      Cpu Time:           ";convert_Time(Beg_CPUTIM)
  133.     Print "      Buffered I/O Count:     ";format$(beg_bufio,"###,###")
  134.     Print "      Direct I/O Count:       ";format$(Beg_dirio,"###,###")
  135.  
  136.  
  137. !
  138. ! Your program goes here
  139. !
  140.  
  141.  
  142. Get_Final_Stats:
  143.     Declare Item_list_3 JPI_Item_list(4)
  144.  
  145.     JPI_Item_List(0)::Buff_Len  = 4%                         
  146.     JPI_Item_List(0)::Code      = Jpi$_BUFIO
  147.     JPI_Item_List(0)::Buff_Add  = Loc(BUFIO)     
  148.     JPI_Item_List(0)::Len_Add   = Loc(length)
  149.  
  150.     JPI_Item_List(1)::Buff_Len  = 4%                         
  151.     JPI_Item_List(1)::Code      = Jpi$_CPUTIM
  152.     JPI_Item_List(1)::Buff_Add  = Loc(CPUTIM)    
  153.     JPI_Item_List(1)::Len_Add  = Loc(length)
  154.  
  155.     JPI_Item_List(2)::Buff_Len  = 4%                         
  156.     JPI_Item_List(2)::Code      = Jpi$_DIRIO
  157.     JPI_Item_List(2)::Buff_Add  = Loc(DIRIO)     
  158.     JPI_Item_List(2)::Len_Add  = Loc(length)
  159.  
  160.     JPI_Item_List(3)::Buff_Len  = 4%                         
  161.     JPI_Item_List(3)::Code      = Jpi$_PAGEFLTS
  162.     JPI_Item_List(3)::Buff_Add  = Loc(PAGEFLTS)  
  163.     JPI_Item_List(3)::Len_Add   = Loc(length)
  164.  
  165.     JPI_Item_List(4)::terminator   = 0                           
  166.  
  167.     Sys_status = Sys$getjpiw (,,,JPI_Item_list() by REF,,,)      
  168.                 
  169. Report_Final_Statistics:
  170.     Print                                        
  171.     Print "Program Execution Statistics:"
  172.     Print                                        
  173.     Print "      Page Faults:          ";format$(pageflts-beg_pageflts,"#,###,###")
  174.     Print "      Cpu Time:           ";convert_Time(CPUTIM-Beg_CPUTIM)
  175.     Print "      Buffered I/O Count:     ";format$(bufio-beg_bufio,"###,###")
  176.     Print "      Direct I/O Count:       ";format$(dirio-Beg_dirio,"###,###")
  177.  
  178.  
  179.