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. :-)

32 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
  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
  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