In previous blog installments, I’ve tracked how long it takes for my computer to calculate an extended number of digits of Pi as a performance metric. I called it How Long for Long Pi. There is a new computer to rule the ham shack today. It’s a Mac Mini M4 Pro with 48 GB of RAM. I decided to compare it to my most recent machine tests and see how it does.
I broke out my Python script from last time and started doing test runs. Let’s do a basic comparison to my I7 12th Gen PC with 32 GB of RAM. Those were the top performers in my previous experiment.
Machine (Times are 3 run avg) | Pi to 100K | Pi to 1M | Notes |
i7 Desktop with Win 11 12700A CPU | 6.2 Sec | 12 Min 35.0 Sec | |
i7 Desktop with Ubuntu 12700A CPU | 5.4 Sec | 08 Min 57.2 Sec | |
Mac Mini M4 Pro | 4.47 Sec | 07 Min 27.0 Sec | Executed with Py Editor from Apple App Store |
By this benchmark alone, the new Mac Mini M4 Pro is processing at 16.7% faster than a 2022 generation Intel desktop running Linux. How about 40.8% better than Win 11?
I’ll add some general observations. The Mini doesn’t seem like it’s breaking a sweat. It’s warm to the touch but not overly so. The fan has not come on. I’m typing this blog post while the calculations are happening, so it’s even got a little bit of a handicap.
I did have to make one change to the code, adding a line to allow for a larger string. The version I used is below. Let me know on my socials if you try this.
#-*- coding: utf-8 -*-
# Author: Fatih Mert Doğancan
# Date: 02.12.2014
# Timer Integration and string modification 0-Nov-2024 by Jim Reed
# Timer function Start
import time
start = time.time()
print("Dogancan - Machin 1,000,000 Digits Pi Calculation Start")
#Original Calculation Code goes here
sys.set_int_max_str_digits(1100000)
def arccot(x, u):
sum = ussu = u // x
n = 3
sign = -1
while 1:
ussu = ussu // (x*x)
term = ussu // n
if not term:
break
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(1000000)) # 10000
# calculation code code ends
# timer reports
end = time.time()
print("Dogancan - Machin 1,000,000 digits elapsed calculation time")
print(end-start)