![]() ![]() ![]() |
|
zenourn:
I suspect this isn't the best of benchmarks.
Nar its just a bit of fun mucking around.
Interesting to see your results guys thanks for trying it out 😀
Ding Ding Ding Ding Ding : Ice cream man , Ice cream man
I was interested in seeing how fast this was on an APU2, but I don't have Python installed on those. Here's a Raspberry Pi 3 Model B Plus Rev 1.3 instead...
Find all primes up to: 200000 using 16 processes.
Time elapsed: 517.57 seconds
Number of primes found 17984
I actually wanted to try this after watching this. Was an interesting watch.
https://www.youtube.com/watch?v=hGyJTcdfR1E&t
Ding Ding Ding Ding Ding : Ice cream man , Ice cream man
i7 7700K (CPU running at 4.49 GHz during Prime test)
Loaded Python 3.9 and ran script.
Find all primes up to: 200000 using 32 processes.
Time elapsed: 23.83 seconds
Number of primes found 17984
After a reboot
Find all primes up to: 200000 using 32 processes.
Time elapsed: 15.74 seconds
Number of primes found 17984
Gordy
My first ever AM radio network connection was with a 1MHz AM crystal(OA91) radio receiver.
MacBook Pro (2016) - i7-6700HQ @ 2.6 GHz
Find all primes up to: 200000 using 32 processes.
Time elapsed: 37.9 seconds
Number of primes found 17984
Raspberry Pi400 @ 2GHz
Find all primes up to: 200000 using 16 processes.
Time elapsed: 164.48 seconds
Number of primes found 17984
Since results for a RPi 3B+ have been posted, I thought I'd dig out a RPi 4B (4GB RAM) running a fresh install of RaspPiOS & stock CPU speeds.
Find all primes up to: 20000 using 16 processes.
Time elapsed: 183.29 seconds
Number of primes found 17984
Not a bad performance boost from the previous gen RPi. These wee things are really packing a punch now.
Comparing an 8700k PC with Apples new M1 Macbook Pro:
Both running Python 3.91
8700k 16gb 256gb EVO SSD:
Find all primes up to: 200000 using 24 processes.
Time elapsed: 11.6 seconds
Number of primes found 17984
M1 Macbook Pro 16gb:
Find all primes up to: 200000 using 32 processes
Time elapsed: 12.23 seconds
Number of primes found 17984
Paul (1st post)
This was my 2018 Macbook pro core i7
Jasons-MacBook-Pro:Documents jason$ python3 prime2.py
Find all primes up to: 200000 using 48 processes.
Time elapsed: 22.41 seconds
Number of primes found 17984
Ding Ding Ding Ding Ding : Ice cream man , Ice cream man
My Ryzen 5 1600 rig built some time ago and running a bunch of VMs:
Find all primes up to: 200000 using 48 processes.
Time elapsed: 12.79 seconds
Number of primes found 17984
Edit:
And a Huawei Matebook D15 with a Ryzen 3500U:
Find all primes up to: 200000 using 32 processes.
Time elapsed: 22.26 seconds
Number of primes found 17984
I expected those to be closer TBH. The first one runs Linux, the second Windows. Guess thats the difference between a desktop and mobile CPU!
python test.py
Find all primes up to: 200000 using 32 processes.
Time elapsed: 75.0 seconds
Number of primes found 17984
Python 2.7.17 (default, Sep 30 2020, 13:38:04)
[GCC 7.5.0] on linux2
Intel i7-3820 from 2012.
% python3 prime2.py
Find all primes up to: 200000 using 96 processes.
Time elapsed: 5.65 seconds
Number of primes found 17984
Ryzen 9 3900X on my OpenShift cluster
Hi! I'm TheoM, but you know that already. I run Linux mirrors in NZ together with 2degrees. Like a mirror added? PM me!
https://theom.co.nz | https://theom.nz | https://mirrorlist.mirrors.theom.nz | Providing Free Mirrors Since Ages Ago™
I was curious to see how Python compared to C. I used TinyCC as a comparison, including the compile and execution time. The C programme ran for 2.38 seconds, versus 21.59 seconds for the Python. Adding what appears to be deliberate inefficiencies in the Python code to the C version (checking all candidate numbers, not just odd numbers, and all lower numbers as divisors), the run time for the C version is 5.15 seconds. Python is only three times slower (although the C code is single threaded). I'd consider that pretty good.
#define max_number 200000
int is_prime(int candidate_number)
{
int divisor;
int divisor_end;
int found_prime;
found_prime = 1;
for(divisor = 2, divisor_end = candidate_number / 2; found_prime && divisor <= divisor_end; divisor++) {
if(candidate_number % divisor == 0) found_prime = 0;
}
return found_prime;
}
int main()
{
int num_primes;
int candidate_number;
for(num_primes = 1, candidate_number = 3; candidate_number < max_number; candidate_number += 2) {
if(is_prime(candidate_number)) num_primes++;
}
printf("Number of primes found %d\n", num_primes);
return 0;
}
sJBs: ... Time elapsed: 75.0 seconds
...
Intel i7-3820 from 2012.
Interesting. My 8 core i7-3770 CPU @ 3.40GHz did
$ python find-prime_multicore.py (fixed script)
Find all primes up to: 200000 using 32 processes.
Time elapsed: 121.91 seconds
Number of primes found 17984
$ python find-prime_singlecore.py (original script)
Find all primes up to: 200000 using 32 processes.
Time elapsed: 202.8 seconds
Number of primes found 17984
I wonder how much closer I could get with a clean reboot?
Please keep this GZ community vibrant by contributing in a constructive & respectful manner.
SirHumphreyAppleby:
Here's a Raspberry Pi 3 Model B Plus Rev 1.3 instead...
Time elapsed: 517.57 seconds
Mehrts:
I thought I'd dig out a RPi 4B (4GB RAM)
Time elapsed: 183.29 seconds
Raspberry Pi 4 Model B Rev 1.4 (4 core Cortex-A72 / 8GB RAM)
$ python3 find-prime_multicore.py
Find all primes up to: 200000 using 16 processes.
Time elapsed: 82.66 seconds
Number of primes found 17984
$ python3 find-prime_singlecore.py
Find all primes up to: 200000 using 16 processes.
Time elapsed: 298.08 seconds
Number of primes found 17984
Please keep this GZ community vibrant by contributing in a constructive & respectful manner.
I usually run number crunching Python code these days with pypy, and it does give a reasonable improvement:
$python3 prime.py
Find all primes up to: 200000 using 256 processes.
Time elapsed: 3.01 seconds
Number of primes found 17984
$ pypy prime.py
Find all primes up to: 200000 using 256 processes.
Time elapsed: 1.21 seconds
Number of primes found 17984
|
![]() ![]() ![]() |