Skip to main content

A stupid simple memory profiler.

Project description

profile-this

PyPI - Version PyPI - Python Version

Sometimes you need sophisticated line-by-line profiling for optimizing your Python code. Other times, you just want a quick and basic memory profile chart.

There are plenty of tools for the former use-case, e.g. py-spy or vprof. But not many (or any) tools for the latter use-case.

profile-this is a stupid simple memory profiler for people who just want a basic memory profiling plot without writing one from scratch.

Links

Source Code

PyPI

Example

Install it like this:

pip install profile-this

Do this:

from random import randint
from profile_this import ProfileThis

def func(n=10_000_000):
    return sum([randint(0, i + 1) for i in range(n)])

profiler = ProfileThis()
profiler.start()
func()
profiler.stop()
profiler.plot(
    title="Profile for func", path="docs/func.png"
)

Or this:

with ProfileThis() as profiler:
    func()
    profiler.plot(
        title="Profile for func",
        path="docs/func.png",
    )

Or this:

from profile_this import profilethis

@profilethis(title="Profile for func", path="docs/func.png")
def func(n=10_000_000):
    return sum([randint(0, i + 1) for i in range(n)])

func()

To get this:

func image

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

profile_this-0.1.6.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

profile_this-0.1.6-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file profile_this-0.1.6.tar.gz.

File metadata

  • Download URL: profile_this-0.1.6.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Darwin/22.6.0

File hashes

Hashes for profile_this-0.1.6.tar.gz
Algorithm Hash digest
SHA256 22f580abf3dba22a5d0423495dec69c00d322ed4e85c6a9d396b315918b8caca
MD5 00886f8f181ff96fd4b2852f94e46711
BLAKE2b-256 008b434676e9ac235a4644e161e22f00b20c67dd34f6f0fa765a2b57ceba3d8a

See more details on using hashes here.

File details

Details for the file profile_this-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: profile_this-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Darwin/22.6.0

File hashes

Hashes for profile_this-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 7116bd8ce7ec1ba4f90feecb8911c8c983a6cc974224a2c77f3c290dc726a7c4
MD5 6b4652951fe1e8e001669bee03d1b726
BLAKE2b-256 6570cca55e5c3fa1b73dee90c1d2fc1fede73c119b0b2380b671f207ff29b0e6

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