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.

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.

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

Apple-I... Holy bejezus...

DeleteNice-$$$$$ ;-)

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

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

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.

ReplyDeleteI made a spreadsheet.

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

The fast way to find primes.

ReplyDelete10 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

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.

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

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

Do you have an inkjet printer in your home, office, or school? If so, you are probably familiar with the challenge of finding quality https://qualityinkjetrefills.ca cartridges for a reasonable price. There are some general guidelines that can help you to make the best possible choice in an inkjet cartridge.

ReplyDeleteZX SPECTRUM 48kb 309 seconds

ReplyDelete5 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