Skip to main content

A simple Python package to profile CPU speed by computing the Fibonacci sequence

Project description

CPU Profile

This is a simple package to measure CPU speed by calculating the time it takes to compute Fibonacci numbers. It is useful in contexts where CPU speed is unknown or can fluctuate, such as cloud function environments, and can serve as a rough measure of how long subsequent compute-intensive code will take to run.


pip install cpuprofile


from cpuprofile import profile_cpu

# Calculate the CPU speed by computing Fibonacci numbers.

elapsed_time = profile_cpu()

# elapsed_time is ~0.18 (seconds) on a 2.5 GHz Intel Core i7 2015 Macbook Pro.

# Or, a number can be specified to calculate the nth Fibonacci (default: 28).

elapsed_time = profile_cpu(15)  # 15th Fibonacci; takes around 0.0006 seconds
elapsed_time = profile_cpu(35)  # 35th Fibonacci; takes about 5 seconds


The minimalist approach of recursively calculating Fibonacci numbers as a way to profile the CPU is inspired by:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cpuprofile, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size cpuprofile-1.0.1-py3-none-any.whl (2.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size cpuprofile-1.0.1.tar.gz (2.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page