Languages
[Edit]
EN

CPU Benchmark - single core speed test with Fibonacci Sequence in Python

4 points
Created by:
Chronal
697

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:

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:

py test.py

Example output:

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)

 

See also

  1. CPU Benchmark - Raspberry PI vs Banana PI - single core speed test with Fibonacci Sequence

  2. CPU Benchmark - single core speed test with Fibonacci Sequence in JavaScript

  3. CPU Benchmark - single core speed test with Fibonacci Sequence in Java

  4. CPU Benchmark - single core speed test with Fibonacci Sequence in AssemblyScript

  5. CPU Benchmark - single core speed test with Fibonacci Sequence in Dart

  6. CPU Benchmark - single core speed test with Fibonacci Sequence in PHP

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join