From: IN%"LEICHTER@yale-eng-venus.ARPA" "Jerry Leichter (LEICHTER-JERRY@CS.YALE.EDU)" 7-NOV-1988 16:18:46.44 To: GG.SPY@isumvs.BITNET, ROBERTS@uornsrl.BITNET, INFO-VAX@kl.sri.COM CC: Subj: Re: Need to monitor internal program cpu usage > I need to examine the internal CPU time used by a simulation I've > written. I'd like something that will run along with the > simulation, or perhaps run the simulation under it, and > occassionally peak to find where the program is at and use the info > to build a histogram of time usage vs. location. ... It seems the simplest method would be to uses $SETIMR to request an AST at some interval, then have the AST routine examine the time, and the call frame (to find the return address). It would seem that this routine would have to be in MACRO or (heaven forbid, BLISS). Yes, using $SETIMR is the way to do this; no, you don't need to use MACRO or BLISS. Attached below is a simple routine routine to do this kind of pro- filing. Simply call ProfStart when you want profiling to start, ProfPrint to stop profiling and print results. If you don't call ProfPrint, it will be called automatically when the program exits. I wrote this for use with a particular piece of code I was working on so it may not be completely general. I've included one .h file it uses (vms.h, which provides handy definitions for dealing with VMS), but not a .h file that is specific to the larger piece of code. Among other things, it #include's vms.h, and defines a FILE * named Logger to which output is written (and a symbol name LOGGER to indicate that the debug code is enabled). So, view this as a sketch of how to write this kind of code. Note that, because the timer AST's are requested in user mode, you will get distorted readings around system calls. Still, this will give you some picture of where your code is spending your time. (In VMS V5, you can request that $SETIMR measure CPU time, not elapsed time. This could give you more useful information; it's left as an exercise to the reader....) DEC has a product called PCA (Performance and Coverage Analyzer) that takes this basic idea and expands it into something much more generally usable - this profiler requires some wizardry to use. You might want to look into it. -- Jerry