The number π calculation by spigot algorithm benchmark

The table below consists of the best results for the listed computers. It is open for the further expansion. So if anybody has faster implementation of spigot algorithm for one of systems listed below then please inform the author of this page (to vol.litwr at gmail dot com) and it should be updated. The same is true for the results of other systems missed in the table.

This algorithm speed depends very much on the speed of integer division. So systems with hardware division have a big advantage. The algoritm computations are 16/32-bit with unsigned integers, it gives advantages to 16/32-systems.

The results are time intervals in seconds for the calculation of 100, 1000, 3000 digits. They also contain the upper limits to the number of digits for programs used. The data are sorted by time for 3000 digits.

Every program is satisfying four restrictions: 1) it measures time; 2) it uses an OS function to print digits, it prints 4 digits a time synchronously with the calculation of them; 3) it uses less than 64 KB RAM for the code and data; 4) it utilizes all available RAM below 64 KB limit to get the maximum number of calculated digits, so it is forbidden to restrict artificially the maximum number of digits.

It is guaranteed that all drivers in use are the fastest, different versions of the drivers have the same speed but they may be different in size and minor features.

CPU frequencies given are maximum available (known to me) for computers listed below. They are actual frequencies used during measurements.

FORMAT: Data for CPU and IO timing parts are calculated, so they are only some approximations. They are less accurate for display outputs because timings for the vertical scrolling are not taken into account. They have also some small deviations (about 5%) for tcp/ip connections because of not linear timing for the char output in this case. For some systems, the data was acquired from hardware. Approximated results are shown in blue. The red color is used in cases where the approximation is based on heuristics.


1The automatic DRAM regeneration doesn't work at this clock (@1.78MHz) so it is possible that some hardware and software can't work with this speed. So, for normal system work, the maximum clock frequency is about 1.34 MHz, or 75% of that that used for the results given in the table.

2This computer has only 20 KB of RAM. So the result for 3000 digits is an approximation. Theoretically the MC-10 can use up to 36 KB of RAM but this computer was manufactured for a too short period and a proper memory expansion was not made for it.

3This system doesn't have a ROM routine to print characters on its screen, so this driver contains such a routine.

4The PC-98 standart system timer accuracy is only 1s. So tenths and hundredths of second are approximations.

The results above allow to calculate CPU efficiency for 1 Mhz. The next table contains approximate values of efficiency reciprocals (ER). These values are calculated by multiplication of the time (CPU time only without IO) of the calculation of 3000 digits by the CPU frequency. The ER values are gotten for pi-spigot which uses base 16-bit integer arithmetic. The best ER value for each CPU is taken. The ER value reflects the efficiency of a CPU electronics.

The next table contains details about the tested systems in a chronological order.


The next table contains the sizes of the main loops and the whole programs.
ProgramCPUMain loopTotal
vax-bsd-1VAX34816*4
vax-vms-2VAX34915*2
ibm370cms-1IBM/37036750
bbc-pandora-23201637992
bbc-panos-232016371044
mac601-1PPC601521840+192=2032*4
msdos-5808654635—640
ibmpc-8808654678
atarist30-106803054722
amiga1200-136802054812
mac20-668020541315
atarist-106800056728
amiga-136800056816
ql-36800856366+192=558*1
mac-668000561311
macppc-1PowerPC561840+196=2036*4
pc386-98038657665
geneve-mdos-1TMS9995621001*2
ti99-4a-2eaTMS990062520+626=1146*1
dragon-6309-5630997281+581=862*1
pdp11-unix7-eis-12ofPDP-11/EIS170628+400=1028*4
rt11-eis-13ofPDP-11/EIS170869*2
rsx11-eis-2ofPDP-11/EIS1701109*2
dragon-768093971051+484=1535*1
bk11-bos-9PDP-113701586
bk10-9PDP-113701616
bk11-9PDP-113701652
pdp11-unix7-noeis-8PDP-113781704+400=2104*4
rt11-noeis-11PDP-113782212*2
rsx11-noeis-2PDP-113782416*2
mc10-268034483135*8
arm2-2ARM25161475
arm1-4ARM15401680
scpu64-765816250+768=1018*5[1764+228+2]=1994*7
apple2gs-165816250+768=1018*51906+416=2322*1
msx-9Z80725+768=1493*51799+452=2251*1
abc800-4Z80725+768=1493*54431*8
zx-5Z80725+768=1493*54666*3
bbc-z80-6Z801078+768=1846*52048+289=2337*1
cpm22bios-18Z801078+768=1846*52534—2570
trsdos-m1-4Z801078+768=1848*52544
trsdos-m3-4Z801078+768=1848*52546
cpc-cpm3-14Z801078+768=1846*52544
trsdos-m4-4Z801078+768=1848*52559
cpc-11Z801078+768=1848*52060+575=2635*1
c128-z80-3Z801078+768=1848*5[2304+511+2]=2817*7
cpm22bdos-18Z801078+768=1848*52541—2807
tandy100-480851425+768=2193*52469+415=2884*1
cpm22bios-8080-780801832+768=2600*53320–3325
vic20-465021847+768=2615*5*6[3015+264+2]=3281*7
pet-365021847+768=2615*5*6[3016+263+2]=3281*7
bbc-965021847+768=2615*5*6[2978]+462+[177]=3617*7
atari800xl-765021847+768=2615*5*63189+[1326+177]=4692*7
plus4-1565022353+768=3121*5*6[3505+526+2]=4033*7
c64-1565022353+768=3121*5*6[3717+570+2]=4289*7
c128-1565022353+768=3121*5*6[3731+556+2]=4289*7
cbm2-265092353+768=3121*5*6[3622+423+2]=4047*7
apple2e-465022353+768=3121*5*63735+437=4272*1
bbc-65c02-965022866+768=3634*5*6[3603]+463+[177]=4243*7
apple2c-65c02-465C022866+768=3634*5*64243+432=4675*1
Square brackets combine part sizes that are parts of one file.
*1 it is a sum of Asssember + Basic code sizes.
*2 it is a size of the pure code without a header
*3 it is a size of the TAP-file
*4 it is a size of the assembler + C code without a loader and C-libraries
*5 code size + the size of multiplication lookup table
*6 the 6502 code may be shorter (1871+768=2639) – this makes it 1-2% slower
*7 it is a sum of Asssember + Basic + header/loader code sizes.
*8 it is a size of Basic text that contains embedded ML-code.

Thanks a lot to the people who helped: bqt, ivagor, perestoronin, blackmirror, BigEd, tricky, MMS, Thorham, meynaf, saimo, Don_Adan, mizapf, modrobert, a/b, ...


Download the sources and executables (v77 [196 KB]) pack.

Sources Archive