1
Earlier this year, on the fediverse, @electron_greg posted a short portable Basic program and started collecting timings for various retro machines. But his account is now gone! Fortunately, the computer museum NAM-IP has reconstructed the results, here.
Just in case it’s again lost, here are some quotes:
This is a repost of benchmark of BASIC on various micro proposed by Electron Greg earlier in 2026 but which looks not reachable any more. So we don’t loose that interesting information !
BASIC code is based on the SPIGOT algorithm implementing a continuous base change, see this PDF by Valentin Albillo
SPIGOT – Producing Digits of π one at a timeQuite generic BASIC code (but may require some tuning)
1 N=20: L=INT(10*N/3): DIM A(255): Z$="000000":T$="999999"
2 FOR I=1 TO L: A(I)=2: NEXT I: M=0: P=0: FOR J=1 TO N: Q=0: K=2*L+1
3 FOR I=L TO 1 STEP -1: K=K-2: X=10*A(I)+Q*I: Q=INT(X/K): A(I)=X-Q*K: NEXT I
4 Y =INT(Q/10): A(1)=Q-10*Y: Q=Y: IF Q=9 THEN LET M=M+1: GOTO 7
5 IF Q=10 THEN PRINT STR$(P+1);LEFT$(Z$,M);: P=0: M=0: GOTO 7
6 PRINT STR$(P);LEFT$(T$,M);: P=Q: M=0
7 NEXT J:PRINT STR$(P)
Ranking by increasing time to compute, number without credit are by Greg
RC2014 : 14 (thank you JonV)
BBCMicro : 19
AmstradCPC : 22 (thank you Devlin)
AmstradPCW : 23 (thank you Pete)
AcornElectron : 25
C128 : 27 (fast mode - thank you Jonas H)
LuxorABC80 : 29 (thank you Erik)
SharpMZ700 : 32 (thank you Tim Holyoake)
DAI: 33 (by NAM-IP)
VIC20 : 36
AcornAtom : 37
AppleII : 38 (thank you Jeroen)
TRS80CoCo : 42 (thank you Chip)
Atari800 : 42 (thank you Mark Elliott)
CBMPET : 43
C64 : 43
Dragon32 : 44
SharpMZ80K : 45 (thank you Tim Holyoake)
C16 : 46
Altair8800 : 52
MSX : 53 (thank you Pixel Purrito)
C128 : 56 (default “mode”)
ZX80 : 57
ZXSpectrum : 68 (thank you Adam)
SharpPC1500A : 167 (thank you Karttu)
SharpPC1245 : 405 (thank you Karttu)Our contribution for our Belgian DAI computing 20 PI digits in about 33s
There are also traces of various replies to the original thread, lying around in a detached state…
Here’s one from Tim Holyoake (psychotimmy) which includes an alternative, a primes benchmark.
Here’s an algorithmic clarification from Jeroen Wiert Pluimers, which links to a post of mine where I note
It’s nice to observe that this pi spigot algorithm dates from 1991 - later than most of these micros. Introduced by Rabinowitz as 14 lines of Fortran, and four years later explained in a paper with Wagon.
By 1994 Dik Winter had written his 133-character C version, according to this Usenet thread.
Somewhere nearby, I noted that the point of the basic Basic benchmark was to benchmark various Basics. It wasn’t an invitation to improve the coding or the algorithm or to make something faster but not so portable. But I linked to the Stardot thread “Calculating digits of Pi in Basic” and said:
The best BBC Basic effort I could come up with is towards the end of that thread, producing the requested 20 digits in 2.07 seconds.
I also chose to have a look at how fast a very BBC Basic version of the original algorithm could run on a Beeb. I did that here:
For what it’s worth (very little!) here’s that 8.11 second version in (very) BBC Basic:
0 T%=TIME
1 N%=20: L%=10*N%/3: DIM A%(255): Z$="000000":T$="999999"
2 FORI%=1TOL%:A%(I%)=2:NEXT: M%=0:P%=0:FORJ%=1TON%:Q%=0:K%=2*L%+1
3 FORI%=L%TO1STEP-1:K%=K%-2:X%=A%(I%)*&A+I%*Q%:Q%=X%DIVK%:A%(I%)=X%-K%*Q%:NEXT:Y%=Q%DIV&A:A%(1)=Q%-Y%*&A:Q%=Y%:IFQ%<9PRINT;P%LEFT$(T$,M%);:P%=Q%:M%=0:NEXTELSEIFQ%=9M%=M%+1:NEXTELSEPRINT;P%+1LEFT$(Z$,M%);:P%=0:M%=0:NEXT
4 PRINT;P%:PRINT (TIME-T%)/100;" seconds"
3 Likes
drogon 2
Hm.
If I run the original in my own SBC running BBC Basic4 at 16Mhz then it gives me a time of 1.3 seconds, or an equivalent of 10.4 seconds at the Beebs usual 2Mhz via a simple multiply by 8.
The 2nd “very BBC Basic” one takes 7.36 seconds. (or 0.92 * 8)
I’m not sure I can translate it into my own TinyBasic… Although I have a different Spigot version which I’m really not sure where I got it from, however it 's not as slow as I thought it might be taking 4.48 seconds to calculate 20 digits on my 16Mhz 65C02…, so ~36 seconds on a 2Mhz Beeb if I were ever to run it there.
0 REM Pi - Spigot
140 PR "Pi - Spigot"
150 PR "How many digits (<= 1000)? "; : INPUT N
180 IF (N>1000) OR (N<1) PR "Try again...": GOTO 150
190 REM Storage is modest at about 1/3 N,
196 REM ... however we max. out at 10*N, so about 3000 digits
200 L=(10*N/3)+16 : E=0
220 !&A0=0:REM Zero timer
240 A = TOP : REM Start of free RAM
250 M=0 : P=0
270 REM
280 FOR J=1 TO L :!(A+J+J)=2 : NEXT J
310 REM
320 FOR J=1 TO N
330 Q=0
340 FOR K=1 TO L
345 I=L+1-K : X=10*!(A+I+I)+Q*I
355 T=2*I-1 : Q=X/T
370 !(A+I+I)=X-T*Q
380 NEXT K
385 T=Q/10 : !(A+2)=Q-10*T : Q=T
410 IF Q=9 THEN M=M+1: GOTO 610
420 IF Q<>10 THEN GOTO 540
430 REM Q==10
440 D=P+1 : GOSUB 670
450 IF M<=0 GOTO 500
460 FOR K=1 TO M
470 D=0: GOSUB 670
480 NEXT K
490 REM
500 P=0 : M=0
520 GOTO 610
530 REM Q<>10
540 D=P: GOSUB 670
550 P=Q
560 IF M=0 THEN GOTO 610
570 FOR K=1 TO M
580 D=9 : GOSUB 670
590 NEXT K
600 M=0
610 NEXT J
620 REM
621 PR P-10*(P/10)
630 REM
635 PR "Time: ", !&A0, "centi-seconds"
640 END
650 REM
660 REM Output
670 IF E THEN PR D-10*(D/10);: RETURN
680 IF D=0 THEN RETURN
691 PR D-10*(D/10),".";
700 E=1
710 RETURN
The run:
>RUN
Pi - Spigot
How many digits (<= 1000)? ?20
3.1415926535897932384
Time: 448centi-seconds
-Gordon
EdS 3
That’s rather good then, compared to the listed 19 seconds.
The C64 and VIC20 have nearly identical BASICs and nearly identical effective clock speeds. Why the significant time difference between them? I can’t imagine the badlines stealing that many cycles …
EdS 5
AIUI there’s a bigger disparity in PAL machines, perhaps that’s it?
EdS 7
Thanks - in that thread we get the detailed technical reference by Christian Bauer
The MOS 6567/6569 video controller (VIC-II) and its application in the Commodore 64
and also
The VC-20 is faster than the C64, even setting aside the badline issue. The reason lies in the method of clock generation.
In the C64, the crystal frequency for PAL (17.73 MHz - quadruple color carrier) is divided by 18, resulting in a CPU clock speed of 0.985 MHz. (For NTSC, 14.318 MHz is divided by 14, resulting in a CPU clock speed of 1.02 MHz).
In the VC-20, the color carrier frequency (PAL: 4.433 MHz) is divided by four, resulting in a CPU clock speed of 1.11 MHz. The VC-20 therefore runs at the highest clock speed. (If I remember correctly, in the VIC, the 14.318 MHz for NTSC is divided by 14 again, so it runs at 1.02 MHz, like the C64).
So, the CPU clock speed is about 11% slower on C64, in the land of PAL.
In another place (over on lemon64) I found this:
In total (unless we render sprites) VIC needs to steal 40x25 = 1000 cycles from total 312x63=19656cycles per screen refresh.
That is, a 5% penalty compared to video-off, or VIC-20.
and also a couple more references:
- Hardware Basics Part 1 - Tick Tock, know your Clock
- Hardware Basics Part 2 - A complicated relationship
Does that explain the benchmark difference? It seems to be about 16%:


Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.