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

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

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

ReplyDeleteMy Tandy 102 runs it in 367 seconds.

ReplyDeleteI get 76 seconds on a BBC Master running BBC BASIC 4.

ReplyDeleteThe good old times as we talked about MHz and not GHz or 4 MB RAM and not 1 GB RAM :)

ReplyDelete4MB?!? My first box had 16k, second had 64k, 3rd 512k, fourth 8MB, fifth 64MB..256MB (upgrades) 6th 512MB, 7th 2GB.

ReplyDeleteI only counted desktops that were primary. (Not that a TI-99/4A was a desktop, per se - primary storage was a casette)

Commodore 128 @ 1 MHz: 319

ReplyDeleteCommodore 128 @ 2 MHz: 152

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

ReplyDeleteForget I said that.

ReplyDelete16k, 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).

ReplyDeleteMallard Basic on PCW8256 (4 Mhz Z80):

ReplyDelete58 sec

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

113 sec

- BASIC Sinclair on ZX Spectrum +3: 316 seconds (measured using FRAMES sysvar, so it's rather accurate). How did you measure 388 seconds??

ReplyDelete- 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.

Atari 130XE (Atari BASIC Rev. C) (1.7898 MHz 6502C) 338 seconds

ReplyDeleteTandy 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

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.

ReplyDeleteTandy 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

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.

ReplyDeleteOr you could write it like this.

ReplyDelete10 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.

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

ReplyDeleteI've tested this code on CP/M 2.2 using BBCBASIC.

ReplyDeleteMy N8-2312 : Z180 @24.576MHz.

It does the test in 33.53s.

Coleco ADAM 3.58 MHz Z80A 174

ReplyDeleteSchneider CPC464 - Z80A @ 4Mhz - 141s

ReplyDeleteTRS 80 model I with Level II Basic Z80 @ 1.774MHz - 421s

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

ReplyDeleteCommodore CBM 2001 (European version of PET 2001) - 106 s

ReplyDeleteSharp MZ-731 (4 MHz Z80) 182s

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

ReplyDeleteI forgot to say the 6802 is running MITS BASIC (Microsoft circa 1977)

ReplyDeleteApple I (Apple cassette BASIC) (1.023 MHz 6502) 135 seconds

ReplyDeleteThis 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.