Skip to main content

A module for monitoring memory usage of a python program

Project description

Timem

A simple decorator to profile memory usage and time taken by python functions

Install

pip install timem

Usage

In example.py:

from timem import profile

@profile
def isPal(s):
    return s == s[::-1]

print(isPal("UwU"))

Output:

"isPal" took 10.012 ms to execute

Filename: example.py

Line #    Mem usage    Increment  Occurences   Line Contents
============================================================
    11     20.4 MiB     20.4 MiB           1       @profile
    12                                             def isPal(s):
    13     20.4 MiB      0.0 MiB           1           return s == s[::-1]


True

Some configurations

1. Only profile time

from timem import profile
@profile(memory=False)
def isPalindromeWithDelay(s):
    import time
    time.sleep(3)
    return s == s[::-1]

print(isPalindromeWithDelay("UwU"))

Output:

"isPal" took 10.028 ms to execute

True

2. Only profile memory

from timem import profile

@profile(memory=False)
def isPalindrome(s):
    return s == s[::-1]

print(isPalindrome("sdasdf"))

Output

Filename: example.py

Line #    Mem usage    Increment  Occurences   Line Contents
============================================================
    11     20.6 MiB     20.6 MiB           1       @profile(timer=False)
    12                                             def isPal(s):
    13     20.6 MiB      0.0 MiB           1           return s == s[::-1]


True

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

timem-0.0.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

timem-0.0.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file timem-0.0.0.tar.gz.

File metadata

  • Download URL: timem-0.0.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.10

File hashes

Hashes for timem-0.0.0.tar.gz
Algorithm Hash digest
SHA256 2e2c1f68ee0d498fd3e3a1072bf53837696887a003ac2941aacb1a6fd639adfb
MD5 88efc2db905c11c2166cbff89d07b6f6
BLAKE2b-256 c7c6ee82c2c9506204a9828a47e04a609f86fe337e50cf38767e9b7ab254b060

See more details on using hashes here.

File details

Details for the file timem-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: timem-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.10

File hashes

Hashes for timem-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e21fca1cedb6af35f5cb0606e548b8078b312bba226879c9c042594a4b54f7f7
MD5 6691ee12c45a1f85b855f943640bb063
BLAKE2b-256 14075f410f114ba7fd225ba880275f6c8ea56f974d4e41d8533593988a353faf

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