How Long for Long Pi – Part 2

In a previous blog post I considered how I might benchmark performance of different computers to understand how they compare across processor generations and maybe in the future across major architectures.

After experimenting with some different Python code, I found a version that is very consistent in it’s performance, seems to run on 1 core of a multi-core processor and can run on Windows and Linux. Here’s the version I am using for calculating Pi to 100K. I sourced it from this Stack Overflow thread.

#-*- coding: utf-8 -*-

# Author:    Fatih Mert Do─čancan
# Date:      02.12.2014

# Timer Integration 18-Jun-22 by Jim Reed

# Timer function Start
import time

start = time.time()
print("Dogancan - Machin 100,000 Digits Pi Calculation Start")

#Original Calculation Code goes here

def arccot(x, u):
    sum = ussu = u // x
    n = 3
    sign = -1
    while 1:
        ussu = ussu // (x*x)
        term = ussu // n
        if not term:
        sum += sign * term
        sign = -sign
        n += 2
    return sum

def pi(basamak):
    u = 10**(basamak+10)
    pi = 4 * (4*arccot(5,u) - arccot(239,u))
    return pi // 10**10

if __name__ == "__main__":
    print (pi(100000)) # 100000

# calculation code code ends
# timer reports

end = time.time()
print("Dogancan - Machin 100,000 digits elapsed calculation time")

I expect to share all my raw data as I get it more in shape, but I am definitely getting some good first impressions. Let’s look at a summary of the tests on 5 machines so far, running Pi to 100K places using the code above on Python in a command prompt / terminal shell.

My PC NamePC TypeOSPi to 100K in X Seconds
(Avg 3 Runs)
TelstarRaspberry Pi 3Raspbian148.395
EdisonRaspberry Pi 4 8GBRaspbian111.263
TeslaIntel i7-7th Gen DesktopWin 1112.997
TeslaIntel i7-7th Gen DesktopUbuntu 2010.960
Charlie DukeIntel i7-8th Gen LaptopWin 1113.342
Charlie DukeIntel i7-8th Gen LaptopUbuntu 2011.627
MarconiIntel i7-12th Gen DesktopWin 116.152
MarconiIntel i7-12th Gen DesktopUbuntu 205.352

No surprise here on machine power. The more powerful the machine, the faster it processed. Now, I don’t think I have enough samples or data to draw a strong conclusion, but on the machines where I could run Ubuntu and Windows, Ubuntu outperformed Windows by at least 12% when averaged across the three runs.

Now let’s step it up an order of magnitude. How long will it take these machines to calculate Pi to 1 Million places. I used the same Python script, just changed the variable. Note on this run because of the long run times, I only ran the Raspberry Pi tests ONCE, the 3 other PC’s show an average of 3x runs.

My PC NamePC TypeOSPi to 1 Million in HH:MM:SS
TelstarRaspberry Pi 3 (1 Run)Raspbian5:12:57
EdisonRaspberry Pi 4 8GB (1 Run)Raspbian3:42:01
TeslaIntel i7-7th Gen DesktopWin 110:26:08
TeslaIntel i7-7th Gen DesktopUbuntu 200:18:21
Charlie DukeIntel i7-8th Gen LaptopWin 110:27:44
Charlie DukeIntel i7-8th Gen LaptopUbuntu 200:19:11
MarconiIntel i7-12th Gen DesktopWin 110:12:25
MarconiIntel i7-12th Gen DesktopUbuntu 200:08:57

One of the really cool pieces of data was the difference in the Marconi runs on Ubuntu 20 was 0.14 seconds from high to low.

The difference in the Windows vs Ubuntu really stood out this time. Here’s the 3 machines data individually:
Charlie Duke was 30.46% faster with Ubuntu
Tesla was 29.78% faster with Ubuntu
Marconi was 28.84% faster with Ubuntu

So, ultimately, I don’t know if this will mean anything to anyone but me, however I am enjoying this so far. Next steps:

  • Complete Household Data Gathering – Will run on Pi 1 and Pi 2, a 10th Gen Intel Laptop and a 2105 Mac Mini
  • Publish my complete data set.
  • Understand if I can port this calculation. Ultimately I’d love to try one of the old museum Cray machines to see if I can add those to the scoreboard.

If you have comments or thoughts for me on this, you can tweet me @N4BFR.