Skip to main content

a simple tool to monitor execution times of functions.

Project description

eprofiler

Execution & Memory Profiler for Python

A lightweight, zero-dependency toolset to monitor execution time and memory usage. eprofiler provides decorators and context managers to help you identify bottlenecks with minimal code.

PyPI version

Installation

pip install eprofiler

Features

  • @timeit: High-resolution execution timing.
  • @memit: Simple peak memory tracking.
  • @profile: Combined time and memory profiling in one shot.
  • Timer: A versatile class that works as both a context manager and a decorator.
  • Stats Capture: Pass a dictionary to handle results programmatically instead of printing.

Usage

1. Basic Timing (@timeit)

By default, decorators print a results dictionary to the console.

from eprofiler import timeit

@timeit(label="Computation")
def my_func():
    return sum(i**2 for i in range(100000))

my_func()

Output: {'label': 'Computation', 'function': 'my_func', 'duration': 0.008...}

2. Capturing Results in a Dictionary

If you pass a dictionary as the first argument, eprofiler populates it with the results instead of printing.

from eprofiler import timeit

results = {}

@timeit(results)
def process_data():
    # ... logic ...
    pass

process_data()
print(f"Time taken: {results['duration']} seconds")

3. Comprehensive Profiling (@profile)

Track both time and memory (current and peak) simultaneously.

from eprofiler import profile

@profile(label="Heavy Task")
def memory_intensive():
    return [x for x in range(1000000)]

memory_intensive()

Output: {'label': 'Heavy Task', 'function': 'memory_intensive', 'duration': 0.04, 'peak': 324502, 'current': 1204}

4. The Timer Class

The Timer class is perfect for timing specific blocks of code or being used as a persistent profiler.

from eprofiler import Timer

# Use as a context manager
with Timer("Database Query") as t:
    # ... code to time ...
    pass
print(t.stats)

# Use as a decorator
@Timer("Critical Path")
def critical_logic():
    pass

Links


Accuracy Note

When using @profile or @memit, Python's tracemalloc is enabled. This adds a slight "Tracer Tax" (overhead) to execution time. For the most precise timing-only results, use @timeit.

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

eprofiler-0.0.6.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eprofiler-0.0.6-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file eprofiler-0.0.6.tar.gz.

File metadata

  • Download URL: eprofiler-0.0.6.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for eprofiler-0.0.6.tar.gz
Algorithm Hash digest
SHA256 4a94fc586c30bbe6f1e6dec9d8bc1d0044999c4e3309284a58495b7fcdc80b75
MD5 eb0ce759d9fa550e448b8d8dfd7b9427
BLAKE2b-256 8c402be4701b53d583e60a44313b60d7693afaad0d182211288a0db3ee080cc7

See more details on using hashes here.

File details

Details for the file eprofiler-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: eprofiler-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for eprofiler-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 3f54beae163ebb02c0f6e457ef847c4def7ed3be6c56a30392eb42b64f33167f
MD5 019c7b019cf76f6b51d04df9aadd10cb
BLAKE2b-256 0237709909d3cb9b31d1ec57e6bd9dc6a63d30fbfda4764a61cc3f1586575c6b

See more details on using hashes here.

Supported by

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