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: 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(100000)) # 100000 # calculation code code ends # timer reports end = time.time() print("Dogancan - Machin 100,000 digits elapsed calculation time") print(end-start)
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 Name||PC Type||OS||Pi to 100K in X Seconds|
(Avg 3 Runs)
|Telstar||Raspberry Pi 3||Raspbian||148.395|
|Edison||Raspberry Pi 4 8GB||Raspbian||111.263|
|Tesla||Intel i7-7th Gen Desktop||Win 11||12.997|
|Tesla||Intel i7-7th Gen Desktop||Ubuntu 20||10.960|
|Charlie Duke||Intel i7-8th Gen Laptop||Win 11||13.342|
|Charlie Duke||Intel i7-8th Gen Laptop||Ubuntu 20||11.627|
|Marconi||Intel i7-12th Gen Desktop||Win 11||6.152|
|Marconi||Intel i7-12th Gen Desktop||Ubuntu 20||5.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 Name||PC Type||OS||Pi to 1 Million in HH:MM:SS|
|Telstar||Raspberry Pi 3 (1 Run)||Raspbian||5:12:57|
|Edison||Raspberry Pi 4 8GB (1 Run)||Raspbian||3:42:01|
|Tesla||Intel i7-7th Gen Desktop||Win 11||0:26:08|
|Tesla||Intel i7-7th Gen Desktop||Ubuntu 20||0:18:21|
|Charlie Duke||Intel i7-8th Gen Laptop||Win 11||0:27:44|
|Charlie Duke||Intel i7-8th Gen Laptop||Ubuntu 20||0:19:11|
|Marconi||Intel i7-12th Gen Desktop||Win 11||0:12:25|
|Marconi||Intel i7-12th Gen Desktop||Ubuntu 20||0: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.