14.12 TimeHistory Interface

ORIGIN '~beta/basiclib/betaenv';
INCLUDE '~beta/sysutils/time';
---lib:attributes---
timeHistory:
  (* pattern to keep track of history of CPU times;
   * if called with TRUE, current time and used CPU 
   * time is printed on the stream S (default screen[])
   *)
  (# t: [4] @ integer;
     top: @integer;
     S: ^stream;
     display: @boolean
  enter display
  do (if (top+1 -> top) > t.range then t.range -> t.extend if);
     cpuTime -> t[top];
     (if display then
         (if S[] = NONE then screen[] -> S[] if);
         systemtime -> formattime -> S.putline;
         (if top > 1 then
             'Time this slot: \t' -> S.puttext;
             ((t[top] - t[top-1]) div 1000000) -> S.putint; 
             ' sec. \nAccumulated time: \t' -> S.puttext;
             ((t[top] - t[1]) div 1000000) -> S.putint; 
             ' sec.\n' -> S.puttext
     if)if)
  #)


14.12 TimeHistory Interface
© 1994-2002 Mjølner Informatics
[Modified: Sunday August 2nd 1998 at 19:17]