home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / piwg / a000014.ada < prev    next >
Encoding:
Text File  |  1988-05-03  |  725 b   |  23 lines

  1. --
  2. --  this function returns the user time on a Unix system
  3. --  by interfacing to the c library to access the times
  4. --  routine
  5. --  (This version tested on Gould 9780)
  6. --
  7.   function CPU_TIME_CLOCK return DURATION is
  8.     type BUF is array(1..4) of INTEGER;
  9.     CPU_TIME_AS_DURATION : DURATION;
  10.     TIME_BUF : BUF;
  11.     procedure TIMES (TIME_BUF: out BUF);
  12.     pragma INTERFACE (C,TIMES);
  13.   begin
  14. --
  15. --  times returns the user time and system time in units of
  16. --  1/60 seconds
  17. --
  18.     TIMES(TIME_BUF);
  19.       CPU_TIME_AS_DURATION := DURATION(DURATION(TIME_BUF(1))/60.0);
  20. --    CPU_TIME_AS_DURATION := DURATION(DURATION(TIME_BUF(1) + TIME_BUF(2))/60.0);
  21.     return CPU_TIME_AS_DURATION;
  22.   end CPU_TIME_CLOCK;
  23.