Time That Sort

Author(s): Dale Fritz
Publication: SWYM
Pub Details: SWYM v5 n5 May 1990 (Volume 5, Issue 5)
Date: May 1990
Pages: 6

I recently wanted to time two versions of a sort program and found that it can be done quite easily on both the 2068 and the 1000.

The method is similar to a stopwatch. Read a Time (T0) at the beginning and a Time (T1) at the end of a program portion. The elapsed time is:

TIME = (T1-T0)/60 seconds.

FOR THE 2068:

T = 65536*PEEK 23674+256*PEEK
    23673+PEEK 23672

Try this:

10 REM ..2068 TIMER CHECK..
30 LET t0=65536*PEEK 23674+256*PEEK 23673+PEEK 23672
40 FOR i=1 TO 500
50 NEXT i
60 LET t1=65536*PEEK 23674+256*PEEK 23673+PEEK 23672
70 LET time=(t1-t0)/60
90 PRINT "time=";time;" seconds"
100 GO TO 30

FOR THE 1000:

T = PEEK 16436+256*PEEK 16437

There are some differences with the 1000:

1.The timer works only in SLOW
2.The timer counts backwards, so the time formula becomes:

TIME = (T0-T1)/60

3.The time cycle is about 9 minutes, so it’s possible to get a “negative” time, if your sample is over the break period. The soution is to add 32768/60 if (T0-T1)/60 is negative.

Try this:

10 REM ...1000 TIMER CHECK..
15 SLOW
20 LET CYCLE=32768/60
30 LET T0=PEEK 16436+256*PEEK 16437
40 FOR I=1 TO 500
50 NEXT I
60 LET T1=PEEK 16436+256*PEEK 16437
70 LET TIME=(T0-T1)/60
80 IF TIME>=0 THEN GOTO 100
90 LET TIME=TIME+CYCLE
100 PRINT "TIME=";TIME;" SECONDS"
110 GOTO 30

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.