Page 1 of 1

ZX81 BASIC performance

Posted: Mon Oct 03, 2016 12:28 pm
by cpcoxygen
I've recently received a ZX81 and having lots of fun with it. However I have a question about BASIC performance in comparision with a ZX Spectrum which I hope someone can shed light on.

I know the CPU is clocked at 3.25 instead of 3.5 MHz and that the CPU has to work harder to update the screen but I did a simple speed comparison and I found the ZX81 to be vastly slower even in FAST mode.

I typed this simple program:
10 for a=1 to 100
20 print a;
30 next a

The ZX Spectrum completed the above in about 1.8 seconds. The ZX81 was 36.4 seconds. Thinking this was due to the extra load the CPU has to work with to display screen content I changed to FAST mode. I expected the ZX81 to be behind but close to the Spectrum but instead I got a result of 10.7 seconds. About 6 times slower.

Surely in FAST mode the CPU wasn't under stress updating the screen? I know the RAM chips may be somewhat slower but surely not that much and the CPU is almost on par with the Spectrum? Was ZX81 BASIC not as streamlined as on the Spectrum?

I know this is not an conclusive test but could anyone shed any light on this? Thanks.

Re: ZX81 BASIC performance

Posted: Mon Oct 03, 2016 12:50 pm
by Paul
In fact the ZX81 is stressed while printing in fast mode as well.
The spectrum has a fixed video ram.
There for no extra effort is needed when printing.
The ZX81 has a variable screen size and position.
When printing to the screen it needs to move the content of the ram around in order to find place to print at.
At least if memory is limited.
On a 16k ZX81 the problem should not occur.
kind regards Paul

Re: ZX81 BASIC performance

Posted: Mon Oct 03, 2016 10:15 pm
by 1024MAK
PRINTing to the screen is slow on both machines. But a ZX81 with 3k bytes or less of RAM is even slower, as Paul explained.

In fact, some parts of the ZX81 BASIC ROM code (if run at the same CPU speed as a ZX Spectrum) are slightly faster. As the ZX Spectrum ROM code has more conditions in it.

So, for speed, don't write to the screen unless you have to. And try not to do any writing to the screen in any loops.

One thing to keep in mind when comparing different BASICs, is that the ROM is made up of machine code instructions for the CPU. Sinclair wanted maximum functionality with the most features that could be fitted in (and some). So the writers used space efficient code. Some of this was at the expense of speed... [ZX81 = 8k bytes, ZX Spectrum = 16k bytes, BBC B = nearly 32k bytes, MTX = 24k bytes etc...]

Mark

Re: ZX81 BASIC performance

Posted: Thu Oct 13, 2016 3:01 pm
by zsolt
Hi,

Some years ago, when i dealt with benchmark tests, i got same result - printing is very slow.
(and in '83 too - when i decided to learn the z80 mc programming :mrgreen: )
Paul wrote:The ZX81 has a variable screen size and position. When printing to the screen it needs to move the content of the ram around in order to find place to print at. At least if memory is limited. On a 16k ZX81 the problem should not occur.
It depends on the size of the variables area. If there is just one loop counter, then the time difference is not significant (see this little video), but...
if we run the next code (the "DIM"-line increases the variables area), then the time difference is more than 6% (16k: 37.8 sec vs. 1K:40.3 sec)

Code: Select all

 1 DIM A(100)
10 FOR I=1 TO 100
20 PRINT I;
30 NEXT I
Regards,
Zsolt

Re: ZX81 BASIC performance

Posted: Fri Oct 28, 2016 4:28 pm
by zsolt
Hi,
I ran a few more tests, and I think I've found the cause of problem above - the PRINT-FP routine is the bottleneck.
It is not by chance that this section has been completely rewritten for the speccy's rom.
the values are in seconds
the values are in seconds
Speed_tests.png (15.57 KiB) Viewed 5960 times
Regards,
Zsolt