Saturday 9 January 2010

8 Bit Home Computer Benchmarks

Over the years I've collected quite a few 8 bit home computers. Out of curiosity I decided to write a simple prime sieve benchmark to compare their implementations of BASIC.

10 LET W=500:DIM F(W):LET P=1:LET A=3
20 LET F(P)=A:LET P=P+1:IF P>W THEN STOP
30 LET A=A+2:LET X=1
40 LET S=A/F(X):IF S=INT(S) THEN 30
50 LET X=X+1:IF X<P AND F(X)*F(X)<=A THEN 40
60 GOTO 20

Here are the results from a few of the machines I have to hand:

System
CPU
Time
Acorn Electron
2.0MHz 6502
138
Amstrad CPC464
4.0MHz Z80A
140
Commodore C64
1.0MHz 6510
254
Commodore Plus/4
1.0 MHz 8501
267
Tandy 64K CoCo 2
0.895MHz 6809E
271
Atari 800XL
1.8MHz 6502
316
Sinclair Spectrum +3
3.55MHz Z80A
388

Let me know how long it takes to run on your favourite classic computer. :-)

42 comments:

  1. One caveat: BBC Basic, as used by the Electron, was pretty fast generally, but exceptionally fast if you happened to use single-letter variable names...

    ReplyDelete
  2. I get 101 seconds on a BBC Model B running BBC BASIC 2.

    ReplyDelete
  3. My Tandy 102 runs it in 367 seconds.

    ReplyDelete
  4. I get 76 seconds on a BBC Master running BBC BASIC 4.

    ReplyDelete
  5. The good old times as we talked about MHz and not GHz or 4 MB RAM and not 1 GB RAM :)

    ReplyDelete
  6. 4MB?!? My first box had 16k, second had 64k, 3rd 512k, fourth 8MB, fifth 64MB..256MB (upgrades) 6th 512MB, 7th 2GB.
    I only counted desktops that were primary. (Not that a TI-99/4A was a desktop, per se - primary storage was a casette)

    ReplyDelete
  7. Commodore 128 @ 1 MHz: 319
    Commodore 128 @ 2 MHz: 152

    ReplyDelete
  8. I would also love to see how fast Woz's Integer BASIC would run this.

    ReplyDelete
  9. Forget I said that.

    ReplyDelete
  10. 16k, we dreamed of 16k, first machine I built had 1k, you tell young folks that now-a-days and they wont believe you (imaging the Yorkshire accesnt for yourselves).

    ReplyDelete
  11. Mallard Basic on PCW8256 (4 Mhz Z80):
    58 sec

    Locomotive Basic 1.1 on CPC 6128 (4 Mhz Z80):
    113 sec

    ReplyDelete
  12. - BASIC Sinclair on ZX Spectrum +3: 316 seconds (measured using FRAMES sysvar, so it's rather accurate). How did you measure 388 seconds??
    - Mallard BASIC on ZX Spectrum +3 using CP/M: 115 seconds.
    - Mallard BASIC on ZX Spectrum +3 using CP/M adding this line to the program:

    5 DEFINT A-Z: DEFSNG S

    105 segundos.

    ReplyDelete
    Replies
    1. Sinclair BASIC on Spectrum +2: 387 seconds. So I think 388 seconds on a +3 is more than right. Maybe the method you used is not that accurate... Face it: built-in BASIC on Spectrum machines is definetely not fast.

      Delete
  13. Atari 130XE (Atari BASIC Rev. C) (1.7898 MHz 6502C) 338 seconds
    Tandy Color Computer 3 (Color BASIC 2.0) (1.7896 MHz 6809) 295 seconds
    Sony F1XV MSX2+ (MSX Microsoft BASIC 3.0) (3.5795 MHz Z80A) 260.0667 seconds
    Commodore VIC-20 (Microsoft BASIC 2a) (1 MHz 6502) 234 seconds
    Apple IIe Enhanced (Applesoft II) (1.02272714286 MHz 65C02) 211 seconds
    Apple IIe Enhanced (Integer BASIC) (1.02272714286 MHz 65C02) 134 seconds

    To get the Integer BASIC time I changed the 'STOP' in line 20 to 'END' and line 40 to:
    40 LET S=A MOD F(X):IF S=0 THEN 30

    ReplyDelete
  14. There is an error in my last post. The Tandy Color Computer 3 time shown was run at 0.8948 MHz. Also, it was "Extended" Color BASIC 2.0.

    Tandy Color Computer 3 (Extended Color BASIC 2.0) (0.8948 MHz MC68B09E) 295 seconds
    Tandy Color Computer 3 (Extended Color BASIC 2.0) (1.7896 MHz MC68B09E) 147 seconds
    Tandy Color Computer 3 (Disk Extended Color BASIC 2.1) (0.8948 MHz MC68B09E) 300 seconds
    Tandy Color Computer 3 (Disk Extended Color BASIC 2.1) (1.7896 MHz MC68B09E) 149 seconds

    ReplyDelete
  15. 220 seconds on a TRS-80 Micro Colour Computer (MC-10). The MC-10 was the little brother of the TRS-80 Colour Computer 2. In general its Basic runs somewhere between 10-15% faster than the Coco's.

    ReplyDelete
  16. Or you could write it like this.

    10 LET W=500:DIM F(W):LET P=1:LET A=3:LET F(P)=A
    20 FOR P=2 TO W
    30 LET A=A+2:LET X=1
    40 LET S=A/F(X):IF S=INT(S) THEN 30
    50 LET X=X+1:IF X<P AND F(X)*F(X)<=A THEN 40
    60 LET F(P)=A
    70 NEXT P

    For machines that support DEFINT and DEFSNG you can add this:
    0 DEFINT X,P,A,F,W:DEFSNG S

    For some reason I couldn't define W as an integer in the original code on the VZ/Laser, it didn't exit properly.

    A VZ200 emulator said just under 205 for this version. FOR NEXT is sure to have different results though and the emulator I used probably doesn't have exact timing yet.
    I'm using a patched ROM that re-enables some of the Level II BASIC commands so don't assume it works on a standard VZ/Laser either.

    ReplyDelete
    Replies
    1. Found this via Google. So... ten year reply to the original post and seven years replying to the above comment.

      Confused as to the above VZ comments - the original 2010 code worked as is (copy and paste).

      Emulator : JVZ200 4 minutes 58 seconds.
      Emulator : VZEM (Feb 2020 release) 5 minutes 16 seconds.

      Our BASIC was slow compared to most others !

      Delete
  17. Commodore +4 has 1.8 MHz CPU. 50 bad lines and other 153 lines for screen area where CPU has to be slower make average CPU frequency equal to 1.15 MHz. Commodore Basic is old and slow. AMSTRAD LOCOMOTIVE BASIC is much newer and faster. So it is not only the hardware benchmarks but BASICs benchmarks...

    ReplyDelete
  18. I've tested this code on CP/M 2.2 using BBCBASIC.
    My N8-2312 : Z180 @24.576MHz.
    It does the test in 33.53s.

    ReplyDelete
  19. Coleco ADAM 3.58 MHz Z80A 174

    ReplyDelete
  20. Schneider CPC464 - Z80A @ 4Mhz - 141s

    ReplyDelete
  21. TRS 80 model I with Level II Basic Z80 @ 1.774MHz - 421s

    ReplyDelete
  22. Raspberry Pi V2 FUZE - 1 second! (Checked by displaying all 500 prime numbers generated).

    ReplyDelete
  23. Commodore CBM 2001 (European version of PET 2001) - 106 s

    ReplyDelete
  24. Sharp MZ-731 (4 MHz Z80) 182s

    ReplyDelete
  25. 6802 running at 1.87 Mhz that I built (serial IO only): 110 seconds.

    ReplyDelete
  26. I forgot to say the 6802 is running MITS BASIC (Microsoft circa 1977)

    ReplyDelete
  27. Apple I (Apple cassette BASIC) (1.023 MHz 6502) 135 seconds

    This Apple I is actually an emulation under MAME 0.184, running at original speed. Apple's cassette BASIC was also written by Steve Wozniak and was the predecessor to Integer BASIC; it is very similar in most respects, except for the latter's added graphics features. However, the program did need an added loop at the start to initialize the sieve array F():

    11 FOR I=1 TO W:F(I)=0:NEXT I

    since this version of Apple BASIC did not initialize arrays automatically.

    The time is almost identical to Tim Locke's for Integer BASIC. Given that the two versions of BASIC are closely related, this isn't surprising. As long as the program doesn't do much I/O and fits within memory, an Apple I is almost identical to an Apple II in computing speed.

    ReplyDelete
    Replies
    1. Heh, read more carefully. I'm not exactly made of money. :)

      I think I can vouch for the emulation accuracy, though, both because MAME offers a pretty solid platform for accurate machine emulation if the driver for the specific system is written properly, and since I did a fair amount of research some years back in making sure the Apple I's emulation actually worked according to the machine's circuitry.

      Delete
  28. Just to illustrate how far we've come, A Core i7 @ 3.6 GHz running Decimal BASIC (ANSI Full BASIC compatible interpreter) runs in .07 seconds. The Decimal BASIC compiled version runs in .0133 seconds. Decimal BASIC compiler automatically creates Lazarus Pascal source code that is then compiled into true machine language. No messing with P-Code interpreters or the like.

    ReplyDelete
  29. I made a spreadsheet.

    https://docs.google.com/spreadsheets/d/1J_ZKDCw_acPxsWOWhfFx7H1AM5SuZ6iW-Yojx1Q59cA/edit?usp=sharing

    ReplyDelete
  30. The fast way to find primes.

    10 X=0:J=0:I=0
    100 CLS
    110 PRINT "Welcome to the prime number generator."
    115 N = 32767
    120 INPUT "Upper limit (32767)";N
    130 FOR I=3 TO N STEP 2:FOR J=2 TO SQR(I):X=I/J:IF X<>INT(X) THEN NEXTJ:PRINTI;:NEXTI:ELSE PRINT".";:NEXTI
    230 PRINT
    240 PRINT "Finished"
    260 END

    ReplyDelete
    Replies
    1. Yeah yours is a faster way to do this particular problem but that's irrelevant to a benchmark. The purpose isn't to find the fastest way to solve a problem, it's to find a program that will run unmodified (or as close as possible to being unmodified) on every system in the list. Some people don't get it when they say, "Hey, I can use such-and-such a feature of my particular compiler to run even faster!" This isn't what benchmarks are about. To compare system X with system Y, both need to run the same program, not taking advantage of quirks or extensions in either system.

      Delete
  31. Updated Results on Atari 800 (prior to XL & XE series), on unmodified CPU + Chipset, 1982/1983 manufacture-date:

    1. On SDX Dos, + Altirra 1.55 Basic (interpreted) => 1m:33s
    2. On CP/M 2.2 (Rev.1.1) + Microsoft Basic 5.29 (on Atari's Z80-powered Indus-GT disk drive) => 2m:08s

    Original benchmark code is essentially untouched / unmodified, with the addition of automatically turning off ANTIC's (graphics chipset) DMA cycling, thus granting full processing power to 6502 central processor (during benchmark execution).

    ReplyDelete
  32. ZX SPECTRUM 48kb 309 seconds
    5 PAUSE 1: POKE 23672,0: POKE 23673,0: POKE 23674,0
    10 LET W=500:DIM F(W):LET P=1:LET A=3
    20 LET F(P)=A:LET P=P+1:IF P>W THEN GOTO 70
    30 LET A=A+2:LET X=1
    40 LET S=A/F(X):IF S=INT(S) THEN GOTO 30
    50 LET X=X+1:IF X<P AND F(X)*F(X)<=A THEN GOTO 40
    60 GOTO 20
    70 PAUSE 1: LET s=PEEK 23672+256*PEEK 23673+65536*PEEK 23674:LET s=s/50: LET m=INT (INT s/60): LET h=INT (m/60): PRINT "Time: ";h;"h ";m-60*h;"min ";INT ((s-60*m)*100)/100;"s": STOP

    ReplyDelete
  33. As an odd comparison, I made an account on the CDC6500 at the living computer museum and ran the same benchmark code - it took approx 1.1 seconds to run, not bad for a 1967 dinosaur.

    ReplyDelete
  34. STM32F411 Nucleo board (100MHz Cortex M4) running RunCPM: 43.3 seconds.

    ReplyDelete
  35. Atari 800 w/Newell Fastchip, OSS Basic XL using FAST, Antic disabled during run: 89 seconds.

    Mattel Aquarius won't dimension F to 500 (RAM limitation) so I DIMed it to 350. For 350 primes: 106 seconds, rough guess to 500 primes would be about 150 seconds?

    ReplyDelete
  36. Atari 800XL + TurboBasic 1.5 = 92 seconds in graphics mode 5 (80x48 res. light DMA contention), 119 seconds in graphics 8 (320x192 res. heavy DMA contention)

    ReplyDelete
  37. Esp32 (TTGO VGA board $10) running RunCPM CP/M emulator, MBASIC took 20 seconds

    ReplyDelete

Note: only a member of this blog may post a comment.