CPU Benchmark - single core speed test with Fibonacci Sequence in Python
In this short article, I would like to show Fibonacci Sequence test that is run on a single core. The test source code was converted from C++ to Python - check source article.
Example test.py
file:
xxxxxxxxxx
import time
def get_current_time():
return round(1000 * time.time())
a, b = 0, 1
print('Started!');
t1 = get_current_time();
i = 0
while i < 10000:
j = 0
while j < 1000000:
tmp = b
b = a + b
a = tmp
j = j + 1
i = i + 1
t2 = get_current_time();
dt = t2 - t1;
print('Finished!');
print('Result: ', b);
print('Time: ', 0.001 * dt, 's');
Running with python:
xxxxxxxxxx
py test.py
Example output:
xxxxxxxxxx
Started!
Finished!
Result: ...
Time: >199760 s
Conclusion: execution time is very long what is caused by size of integer numbers that are limited by available memory - it is like working with big integer numbers.
Used Python: v3.10.0 (CPython)
Used OS: Windows 10 x64
Used PC:
- Ryzen 9 5900x
- DRR 4 (2x 32GB)
- Samsung SSD M.2 970 EVO (1TB)
- GeForce GTX 970 (4GB RAM)
-
CPU Benchmark - Raspberry PI vs Banana PI - single core speed test with Fibonacci Sequence
-
CPU Benchmark - single core speed test with Fibonacci Sequence in JavaScript
-
CPU Benchmark - single core speed test with Fibonacci Sequence in Java
-
CPU Benchmark - single core speed test with Fibonacci Sequence in AssemblyScript
-
CPU Benchmark - single core speed test with Fibonacci Sequence in Dart
-
CPU Benchmark - single core speed test with Fibonacci Sequence in PHP