Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/kreier/prime
Browse files Browse the repository at this point in the history
  • Loading branch information
kreier committed Dec 14, 2023
2 parents 5048c37 + 2269ea3 commit 83d5e98
Show file tree
Hide file tree
Showing 76 changed files with 199 additions and 8 deletions.
15 changes: 15 additions & 0 deletions arduino/v2.0.2022/results_esp8266.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Calculating prime numbers in Arduino C v2.0.2022
2023/12/12
ESP8266 with 80 MHz

last time in seconds
100 0.001859
1,000 0.040104
10,000 0.905273
100,000 21.511326
1,000,000 538.199219
10,000,000 14038.631 - 3h 53min 58s
25,000,000 51894.422 - 14h 24min 54s
100,000,000 1h 3% 2h 6% - 40h?
1,000,000,000

8 changes: 4 additions & 4 deletions arduino/v5.0.2023/results_esp8266.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ Calculating prime numbers in Arduino C v5.0.2022
ESP8266 with 80 MHz

last time in seconds
100 0.001137
100 0.001136
1,000 0.014878
10,000 0.140965
100,000 1.923395
1,000,000 31.340561
10,000,000 610.143433
25,000,000
100,000,000
1,000,000,000 17026.424 or 4h 43min 46s
25,000,000 2069.988381 or 34 min
100,000,000 13579.361 or 3h 46min 19s
1,000,000,000 13h 13% - 16h 29% - 20h 33%

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions python/v1.0.1991/X5550/1000000000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prime v1.0.1991 in python
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
Primes to 1000000000 took 275399620702.2 microseconds.
Found 50847534 primes. Should be 50847534.
12 changes: 12 additions & 0 deletions python/v1.0.1991/X5550/summary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Summary of prime v1.0.1991 in python
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
last time in microseconds
100 112.7
1000 1532.2
10000 34118.4
100000 633776.6
1000000 15135554.7
10000000 377564319.7
25000000 1380046016.5
100000000 10134258478.1
1000000000 275399620702.2
4 changes: 4 additions & 0 deletions python/v1.1.2000/X5550/1000000000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prime v1.1.2000 in python
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
Primes to 1000000000 took 279719653319.8 microseconds.
Found 50847534 primes. Should be 50847534.
12 changes: 12 additions & 0 deletions python/v1.1.2000/X5550/summary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Summary of prime v1.1.2000 in python
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
last time in microseconds
100 97.1
1000 1499.0
10000 26655.7
100000 620664.8
1000000 14439110.4
10000000 385969817.4
25000000 1409575020.3
100000000 10275299882.4
1000000000 279719653319.8
4 changes: 4 additions & 0 deletions python/v1.1.2000/i5-2520M/100.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prime v1.1.2000 in python
Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
Primes to 100 took 235.6 microseconds.
Found 25 primes. Should be 25.
4 changes: 4 additions & 0 deletions python/v1.1.2000/i5-2520M/1000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prime v1.1.2000 in python
Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
Primes to 1000 took 2214.9 microseconds.
Found 168 primes. Should be 168.
4 changes: 4 additions & 0 deletions python/v1.1.2000/i5-2520M/10000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prime v1.1.2000 in python
Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
Primes to 10000 took 25632.3 microseconds.
Found 1229 primes. Should be 1229.
4 changes: 4 additions & 0 deletions python/v1.1.2000/i5-2520M/100000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prime v1.1.2000 in python
Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
Primes to 100000 took 575529.8 microseconds.
Found 9592 primes. Should be 9592.
4 changes: 4 additions & 0 deletions python/v1.1.2000/i5-2520M/1000000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prime v1.1.2000 in python
Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
Primes to 1000000 took 14574511.4 microseconds.
Found 78498 primes. Should be 78498.
4 changes: 4 additions & 0 deletions python/v1.1.2000/i5-2520M/10000000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prime v1.1.2000 in python
Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
Primes to 10000000 took 394983498.0 microseconds.
Found 664579 primes. Should be 664579.
4 changes: 4 additions & 0 deletions python/v1.1.2000/i5-2520M/100000000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prime v1.1.2000 in python
Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
Primes to 100000000 took 10672338771.5 microseconds.
Found 5761455 primes. Should be 5761455.
4 changes: 4 additions & 0 deletions python/v1.1.2000/i5-2520M/1000000000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prime v1.1.2000 in python
Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
Primes to 1000000000 took 268350361238.9 microseconds.
Found 50847534 primes. Should be 50847534.
4 changes: 4 additions & 0 deletions python/v1.1.2000/i5-2520M/25000000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prime v1.1.2000 in python
Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
Primes to 25000000 took 1491171293.7 microseconds.
Found 1565927 primes. Should be 1565927.
22 changes: 20 additions & 2 deletions python/v1.1.2000/i5-2520M/prime_logging.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# prime v1.1.2000
# prime v1.1.2000 - 2023/12/09
# cycles through limits and writes to the filesystem

import math, time, os, cpuinfo
Expand All @@ -7,13 +7,21 @@
reference = [25, 168, 1229, 9592, 78498, 664579, 1565927, 5761455, 50847534]
time_calc = [0, 0, 0, 0, 0, 0, 0, 0, 0]

def elapsed_time(seconds):
hours = int(seconds/3600)
minutes = int(seconds/60 - hours*60)
sec = int(seconds - minutes*60 - hours*3600)
return(f"{hours}h {minutes}min {sec}s")

if __name__ == "__main__":
for i in range(len(scope)):
last = scope[i]
found = 4 # we start from 11, know 2, 3, 5, 7
primes = [3, 5, 7] # exclude 2 since we only test odd numbers
print(f"Prime numbers to {last} in Python with algorithm v1.1.2000")
start = time.perf_counter_ns()
dot = start
column = 1
for number in range(11, last, 2):
prime = True
for divisor in range(3, int(math.sqrt(number))+1, 2):
Expand All @@ -23,8 +31,18 @@
break
if prime:
found += 1
if (time.perf_counter_ns() - dot) > 2000000000:
print(".", end="")
dot = time.perf_counter_ns()
column += 1
if column > 30:
t = elapsed_time((time.perf_counter_ns() - start)/1000000000)
print(f" {t} - {number} {int(number*100/last)}% ")
column = 1
end = time.perf_counter_ns()
print(f"This took: {(end - start)/1000} microseconds.")
if (end - start)/1000000000 > 2:
print(" ")
print(f"This took: {(end - start)/1000} microseconds. {elapsed_time((end - start)/1000000000)}")
print(f"I found {found} prime numbers. Should be {reference[i]}.\n")
filename = str(last) + ".txt"
with open(filename, "w") as fp:
Expand Down
12 changes: 12 additions & 0 deletions python/v1.1.2000/i5-2520M/summary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Summary of prime v1.1.2000 in python
Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
last time in microseconds
100 235.6
1000 2214.9
10000 25632.3
100000 575529.8
1000000 14574511.4
10000000 394983498.0
25000000 1491171293.7
100000000 10672338771.5
1000000000 268350361238.9 or 74h 32min 30s
4 changes: 4 additions & 0 deletions python/v2.0.2022/X5550/1000000000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prime v2.0.2022 in python
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
Primes to 1000000000 took 108768467297.8 microseconds.
Found 50847534 primes. Should be 50847534.
12 changes: 12 additions & 0 deletions python/v2.0.2022/X5550/summary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Summary of prime v2.0.2022 in python
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
last time in microseconds
100 95.7
1000 914.2
10000 26298.9
100000 245950.8
1000000 5466198.8
10000000 138095740.0
25000000 509184156.6
100000000 3682180884.3
1000000000 108768467297.8
4 changes: 4 additions & 0 deletions python/v3.0.2023/X5550/1000000000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prime v3.0.2023 in python
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
Primes to 1000000000 took 68709592815.0 microseconds.
Found 50847534 primes. Should be 50847534.
12 changes: 12 additions & 0 deletions python/v3.0.2023/X5550/summary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Summary of prime v3.0.2023 in python
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
last time in microseconds
100 85.1
1000 755.6
10000 14408.2
100000 181539.7
1000000 3815344.1
10000000 85336841.4
25000000 315633984.6
100000000 2190772686.6
1000000000 68709592815.0
2 changes: 1 addition & 1 deletion python/v4.0.2023/X5550/100.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
prime v4.0.2023 in python
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
Primes to 100 took 494986.5 microseconds.
Primes to 100 took 600634.8 microseconds.
Found 25 primes. Should be 25.
We used 16 parallel processes.
2 changes: 1 addition & 1 deletion python/v4.0.2023/X5550/1000.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
prime v4.0.2023 in python
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
Primes to 1000 took 445877.9 microseconds.
Primes to 1000 took 425177.1 microseconds.
Found 168 primes. Should be 168.
We used 16 parallel processes.
4 changes: 4 additions & 0 deletions python/v4.0.2023/X5550/10000.txt
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
prime v4.0.2023 in python
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
Primes to 10000 took 438641.6 microseconds.
Found 1229 primes. Should be 1229.
We used 16 parallel processes.
5 changes: 5 additions & 0 deletions python/v4.0.2023/X5550/100000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
prime v4.0.2023 in python
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
Primes to 100000 took 466354.2 microseconds.
Found 9592 primes. Should be 9592.
We used 16 parallel processes.
5 changes: 5 additions & 0 deletions python/v4.0.2023/X5550/1000000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
prime v4.0.2023 in python
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
Primes to 1000000 took 1113699.1 microseconds.
Found 78498 primes. Should be 78498.
We used 16 parallel processes.
5 changes: 5 additions & 0 deletions python/v4.0.2023/X5550/10000000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
prime v4.0.2023 in python
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
Primes to 10000000 took 14873092.0 microseconds.
Found 664579 primes. Should be 664579.
We used 16 parallel processes.
5 changes: 5 additions & 0 deletions python/v4.0.2023/X5550/100000000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
prime v4.0.2023 in python
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
Primes to 100000000 took 294817230.3 microseconds.
Found 5761455 primes. Should be 5761455.
We used 16 parallel processes.
5 changes: 5 additions & 0 deletions python/v4.0.2023/X5550/1000000000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
prime v4.0.2023 in python
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
Primes to 1000000000 took 7516578047.4 microseconds.
Found 50847534 primes. Should be 50847534.
We used 16 parallel processes.
5 changes: 5 additions & 0 deletions python/v4.0.2023/X5550/25000000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
prime v4.0.2023 in python
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
Primes to 25000000 took 49906119.8 microseconds.
Found 1565927 primes. Should be 1565927.
We used 16 parallel processes.
12 changes: 12 additions & 0 deletions python/v4.0.2023/X5550/summary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Summary of prime v4.0.2023 in python
Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
last time in microseconds
100 600634.8
1000 425177.1
10000 438641.6
100000 466354.2
1000000 1113699.1
10000000 14873092.0
25000000 49906119.8
100000000 294817230.3
1000000000 7516578047.4

0 comments on commit 83d5e98

Please sign in to comment.