Commodore PET User Manual page 297

Table of Contents

Advertisement

Keeping time in jiffies is useful for timing program speed to test the
efficiency of a program. A short program is listed below:
10 PRINT"::')fElIiKEYBOARD TESTlIilli":PRINT
20 FOR 1=32 TO 127
30 PRINT CHR$(I);
40 NEXT 1
50 FOR 3=161 TO 255
60 PRINT CHR$(3);
70 NEXT 3
8(1 PRIt-.lT: PRINT: PRINT"iIIi11END TESTiIIiII"
If we were ta time the execution of this program, it would take three steps:
1.
TI (or TIME$) is assigned ta a variable constant near the start (or
wherever vou wish timing ta beginl.
2.
TI (or TIME$) is reassigned ta a different variable constant near the end
(or wherever Vou wish timing ta end).
3.
Subtract the first TI assigned variable from the second. This will give
Vou the amount of jiffv time it took ta process the steps in between.
The listing below shows the three added steps:
Step 1
10 PRINT"::')fElIiKEYBOARD TESTiIIiII": PRINT
15 A=TI
20 FOR 1=32 Ta 127
30 PRINT CHR$(I);
40 NEXT 1
50 FOR 3=161 TO 255
60 PRINT CHR$(3);
70 NEXT
~T
75
B=TI
Step 2
80 PRINT: PRINT: PRINT"iIIi11END TE8TiIIiII"
Step3
100 PRIt..jT:PRINT"TI = ";B-A
At line 15. variable A is set ta the current value of TI.
15
A=TI
A
=
TQl'>0017621
A11'>001762\
Then, as the program is processed. TI increments 60 times everv second. At line
75, 8 is set ta the current value of TI.
75
B=TI
B TIII'>0019531
BII'>0019531
Line 100 subtracts the first value of TI (A) from the second (8).
100
PF~It-n· PF~It-n"TI=".;
E:-A
BII'>0019531
- A11'>001762/
191
284

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cbm

Table of Contents