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.

Installation

pip install cpuprofile

Usage

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

Credit

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.

Source Distribution

cpuprofile-1.0.1.tar.gz (2.0 kB view details)

Uploaded Source

Built Distribution

cpuprofile-1.0.1-py3-none-any.whl (2.5 kB view details)

Uploaded Python 3

File details

Details for the file cpuprofile-1.0.1.tar.gz.

File metadata

  • Download URL: cpuprofile-1.0.1.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

File hashes

Hashes for cpuprofile-1.0.1.tar.gz
Algorithm Hash digest
SHA256 774b5636b2619dcc75d240497b3bb62a43f167862a0eadf959ac55d294a17bca
MD5 61aadc2532a58290515858eb5e49da0f
BLAKE2b-256 9b1472a2d8fb3b7a97c2996262dfd3dd7ef2e7f0b7ce2f7eef35d539ce0ad492

See more details on using hashes here.

File details

Details for the file cpuprofile-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: cpuprofile-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

File hashes

Hashes for cpuprofile-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9991e9c2af83cd4060aacfbaddcd324954d409bcdf676d0d549afa57435e1892
MD5 a84448dff75b2100dab84ae5b18258e6
BLAKE2b-256 48c302813ed0da595c9d32a48098b44f09e1e282f618f4230e613871e4fc792e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page