TIME() function in ALGOL

25 views
Skip to first unread message

a.daniel...@gmail.com

unread,
Jan 11, 2023, 1:13:34 PM1/11/23
to retro-B5500
Hi Paul,
Is the TIME(4) function implemented? I wanted to get an idea of the instruction processing rate in the simulator running in my Firefox browser.  I wrote a tight loop to run 500000 iterations.  It runs for about 10 seconds before prints the output, longer if I increase the iterations.  But it only prints ever prints 0.

  INTEGER I, J, K;
  I := TIME(4);
  WRITE (LINE, <I7>, I);
  FOR K:=0 STEP 1 UNTIL 500000 DO
    BEGIN
      J := I;
      I := J;
    END;
  COMMENT-- TIMER FUNCTION
  I := TIME(4);
  WRITE (LINE, <I7>, I);

The printer output is:
      0
      0

Paul Kimpel

unread,
Jan 12, 2023, 11:21:03 AM1/12/23
to retro-B5500
Yes, TIME(4) is implemented and works, but there are a couple of problems with what you are trying to do. The first is that your COMMENT before the second call on TIME(4) does not have a terminating semicolon, so the line after it is part of the comment, and "I" never gets assigned a second time.

The second is that TIME(4) is not a good choice for this type of timing test. It returns the value of the 6-bit timer, which increments every 1/60 second. When that timer overflows after 64/60 seconds, the system's timer interrupt fires (which you can see on the Operator Console). The MCP then uses that interrupt to maintain the full time-of-day clock, log processor time, update the calendar date, etc.

I think you would be better off using TIME(2) (elapsed processing time in 1/60 seconds). If you want to time the performance of just your program, you don't want that to include the time the system is working on other things like MCP interrupt servicing and any other programs running in the mix.

I modified your program slightly:

BEGIN
  FILE LINE 11 (1, 10);
  INTEGER I, J, K;
  I := TIME(2);

  WRITE (LINE, <I7>, I);
  FOR K:=0 STEP 1 UNTIL 500000 DO
    BEGIN
      J := I;
      I := J;
    END;
  COMMENT-- TIMER FUNCTION;
  K := TIME(2);
  WRITE (LINE, <I7,F10.4>, K, (K-I)/60);
END.

which produces this output on the SPO (I am running a dual-processor configuration):

  5:TIME2/TEST= 1 BOJ 0755
#TIME2/TEST= 1:       0
#TIME2/TEST= 1:    1862 31.0333
 TIME2/TEST= 1 EOJ 0756

Something to keep in mind is that the retro-B5500 emulator does not operate at the clock level. It operates at the instruction level, but attempts to accumulate the number of 1MHz clock ticks each instruction would have taken. The Processor modules execute instructions continuously until they have accumulated about 4ms of emulated time, then insert a delay to allow real time to catch up to emulated time. The way that JavaScript works in a browser, only one thing runs at a time, so it is only during this delay that the other modules can do any work -- I/O, browser garbage collection, browser screen updating, etc. The 6-bit timer resides in Central Control, so its updates can only occur during this delay as well. Thus, if you try to time very short intervals, you'll probably see a lot of jitter in the results.

Finally, there are two additional TIME() values that are not documented in the manuals on bitsavers.org:
  • TIME(5) reports the current date as BCL in MMDDYY format.
  • TIME(6) reports the abbreviation for the day of week in BCL, right-justified over spaces (note that the B5500 MCP still thinks it's operating in the 20th century, so the day-of-week will be wrong) .
You may be interested in trying the attached test program for TIME() functions.
TIME.TEST.card
Reply all
Reply to author
Forward
0 new messages