{ +---------------------------------------------------------------------------+ | | | [WHO]STATISTICS.PAS Collect and Report Statistics | | Scott Bailey, Xerox Corporation Created November 4, 1990 | | | | Modification History | | V1.0-000 11/04/90 RSB Original version | | | +---------------------------------------------------------------------------+ } [ident('V1.0-000'),environment('statistics'), inherit('sys$library:starlet', 'sys$library:pascal$lib_routines', 'whodefs')] module statistics(output); [hidden] const statfaoctl = { Changes here *MUST* match statistics block below } ' Buffered I/O count:!9UL!6* Peak working set size:!6UL' + ' Direct I/O count:!11UL!6* Records scanned:!12UL' + ' Page faults:!16UL!6* Records matched:!12UL' + ' CPU time:!6* !16%D!+!+ Elapsed time: !16%D'; [hidden] type statistics_block = [volatile] record { Statistics snapshot } bio : integer; { Buffered I/O count } pws : integer; { Peak working set, pages } dio : integer; { Direct I/O count } urs : integer; { UAF records scanned } flt : integer; { Page fault count } urm : integer; { UAF records matched } cpuptr : unsigned; { %REF for cpu, for $FAOL } cpu : array [1..2] of integer; { CPU time, 10ms ticks } timptr : unsigned; { %REF for tim, for $FAOL } tim : array [1..2] of unsigned; { System quadtime } end; {record statistics_block} [hidden] var start_stats : statistics_block; { Initial readings } { Collect process statistics and save them in the specified record. Record statistics are not filled in by this routine. } [hidden] procedure get_stats(var info : statistics_block); var args : array [1..6] of item_list_entry; { $GETJPI argument list } begin {procedure get_stats} args := zero; with args[1] do begin itmcod := jpi$_bufio; bufadr := iaddress(info.bio); buflen := 4; end; {with} with args[2] do begin itmcod := jpi$_dirio; bufadr := iaddress(info.dio); buflen := 4; end; {with} with args[3] do begin itmcod := jpi$_pageflts; bufadr := iaddress(info.flt); buflen := 4; end; {with} with args[4] do begin itmcod := jpi$_cputim; bufadr := iaddress(info.cpu); buflen := 4; end; {with} with args[5] do begin itmcod := jpi$_wspeak; bufadr := iaddress(info.pws); buflen := 4; end; {with} check($getjpiw(,,,args)); { Get most of the stuff } check($bintim('-- ::.',info.tim)); { Get current time } end; {procedure get_stats} { Collect starting statistics. Record counts are assumed to be zero. } procedure collect_initial_statistics; begin {procedure collect_initial_statistics} start_stats := zero; get_stats(start_stats); end; {procedure collect_initial_statistics} { Collect statistics, calculate changes from initial stats, and report them to standard output. The number of records scanned and matched must be passed as parameters as we can't collect them here. } procedure report_statistics(scanned, matched : integer); var curr_stats : statistics_block; { Current stuff } buff : varying [300] of char; { Output buffer } begin {procedure report_statistics} get_stats(curr_stats); { Collect most of the stuff } curr_stats.urs := scanned; { Fill in parameters } curr_stats.urm := matched; { Calculate differences between current information and original stuff. (That comparison is not meaningful for some statistics.) } curr_stats.bio := curr_stats.bio - start_stats.bio; curr_stats.dio := curr_stats.dio - start_stats.dio; curr_stats.flt := curr_stats.flt - start_stats.flt; curr_stats.cpu[1] := curr_stats.cpu[1] - start_stats.cpu[1]; { Calculate incremental times. For elapsed, we subtract to get a negative quadword (which will be then be interpreted as a delta time like we want). The CPU time, from above, is in 10ms ticks so we'll multiply (by a negative number) to change it into a delta time also. } lib$subx(start_stats.tim,curr_stats.tim,curr_stats.tim); lib$emul(curr_stats.cpu[1],-100000,0,curr_stats.cpu); { By setting a few pre-reserved references, we can turn the statistics block into a parameter list for $FAOL. } curr_stats.cpuptr := iaddress(curr_stats.cpu); curr_stats.timptr := iaddress(curr_stats.tim); { Format the statistics and display them. Do this a line at a time to avoid overflows or nasty-looking output characters... } $faol(statfaoctl,buff.length,buff.body,curr_stats.bio); writeln; writeln(substr(buff,1,64)); writeln(substr(buff,65,64)); writeln(substr(buff,129,64)); writeln(substr(buff,193,67)); end; {report_statistics} end. {module statistics}