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(timer=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
Release history Release notifications | RSS feed
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.1.tar.gz
(6.7 kB
view details)
Built Distribution
timem-0.0.1-py3-none-any.whl
(7.6 kB
view details)
File details
Details for the file timem-0.0.1.tar.gz
.
File metadata
- Download URL: timem-0.0.1.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7f174593fa378eb2378faee0bff8d94de666c29cfb95ba46c3019f3fc1ac278 |
|
MD5 | 54885daa0bf5ffd84cfb494c82773ec8 |
|
BLAKE2b-256 | 11126e52155233340d200f2f44cbf78c19673b2205f3562c6b9c033ce0a94d26 |
File details
Details for the file timem-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: timem-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.6 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 662b3cf89f795dca3bee01a50343ac77340784becdfdef326a5fc0c6b9236e62 |
|
MD5 | 8bc0d555e1f856d7bbedce6c5b907e74 |
|
BLAKE2b-256 | bfb45d0f09729fde356253caa62d17bfc9dd15969ee4d9e09020a8ba85868fe0 |