bigprime.c

I started writing computer programs in 1965, and I've owned personal computers since 1977. News flash: computers are faster than they used to be! This page provides proof from my personal experience.

The April 1984 issue of Scientific American included an article (page 26) on the Mersenne prime 2 ^ 132049 - 1. I had a IBM PC (running COHERENT, but that's another story) with a C compiler and plenty of spare cycles, so on 3/30/84 I wrote a simple program bigprime.c to compute it. It ran in 24.5 hours on an IBM PC. The program's output is a prime with 39751 decimal digits.

My C code long predates the ANSI/ISO C standard, it's in K&R C, but the unchanged code still compiles and runs. In the intervening decades, I've compiled it on various computers, timed its execution, and added a comment line to the source to document the timing. In 2010, it took under 30 seconds on the HP desktop in my office. That's a speedup of about 3000x over 26 years (37% per annum compounded annually, a good rate of return!). Here are the timing comment lines from the source:

 * Takes 24.5 hours on IBM PC.
 * Takes 14.25 hours on the Z8001 (segmented).
 * Takes 3.24 hours on the hp 386.
 * Takes about 3 hours on stevesf (i386/20), about 4:15 on belmont.
 * Takes about 32 minutes on jsbach (i486/33).
 * Takes about 3 minutes on acer (PIII/500) 4/4/01.
 * Takes about 49 seconds on eMach1 (Celeron 2.3 GHz) 7/17/03.
 * Takes about 29 seconds on hppav2 (AMD Phenom II 830, 2.80 GHz) 10/03/10.
 * Takes about 40 seconds on macair (Intel Core 2 Duo 1.86 GHz) 8/29/12.
 * Takes about 24 seconds on macair2 (Intel Core I7 2.2 GHz) 6/05/20.
 * Takes about 20 seconds on macair3 (Intel QuadCore Core I5 1.1 GHz) 6/05/20.
			

Sadly, the earlier entries are undated and don't give the processor clock rate. But I can resurrect the dates from the given computer names: the IBM PC entry is from 1984, the Z8001 only slightly later, stevesf from 1990, jsbach ca. 1992. Later entries are dated and give clock rates.

A decade later, I recoded bigprime.c as a much more efficient program bigprime2.c. The changes are minor, but the revised code runs about ten times faster than the original. Of course, speed is not really important per se; the point of interest is the timing comparison from unmodified source over several decades.