Skip to main content

Profile a function using a simple decorator

Project description

function_profile decorator

Provides decorator for time and memory profiling of functions.

Metrics:

  • time - time for a single function call
  • memory - peak memory used by the function. The peak memory is the difference between the starting minimum value, and the highest value.

Usage:

from function_profile_decorator import profile

@profile(time_prof=True, mem_prof=True)
def factoriel_loop(n: int) -> int:
    """Calculate factoriel non-recursive."""
    fac: int = 1
    for i in range(1, n + 1):
        fac = fac * i
    return fac

factoriel_loop(n=100)

Output:

factoriel_loop(, n=100)

Time 0.00001450

Memory 0.0546875

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 func-profile-decor, version 0.1.7
Filename, size File type Python version Upload date Hashes
Filename, size func_profile_decor-0.1.7-py3-none-any.whl (3.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size func-profile-decor-0.1.7.tar.gz (2.1 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