Track the RAM usage (resident set size) of a process and its descendants in real time.
Project description
memsparkline
Track the RAM usage (resident set size) of a process, its children, its children's children, etc. in real time with a Unicode text sparkline. See the average and the maximum usage after the process exits, as well as the run time.
Examples
> memsparkline -- chromium-browser --incognito http://localhost:8081/
▁▁▁▁▄▇▇▇█ 789.5
avg: 371.0
max: 789.5
time: 0:00:12.0
> memsparkline -n -o log du /usr/ >/dev/null 2>&1 &
> tail -f log
█ 2.8
▆█ 3.3
▆▇█ 3.6
▆▇▇█ 3.9
▆▇▇█▆ 3.3
▆▇▇█▆▆ 3.3
▆▇▇█▆▆▆ 3.3
▆▇▇█▆▆▆▆ 3.3
▄▅▅▆▅▅▅▅█ 5.2
▄▅▅▆▅▅▅▅██ 5.2
avg: 3.7
max: 5.2
time: 0:00:10.1
Compatibility and limitations
memsparkline works on POSIX systems supported by psutil. It has been tested on Debian, Ubuntu, FreeBSD, NetBSD, and OpenBSD. It seems to work on Windows, but Windows support has received minimal testing. The sparkline displays incorrectly in the Command Prompt and ConEmu on Windows 7 with the stock console fonts but correctly on Windows 10 with the font NSimSun.
memsparkline measures run time less precisely than time(1). The granularity with which it measures run time depends on the --wait
option.
Installation
memsparkline requires Python 3.7 or later.
Installing from PyPI
The recommended way to install memsparkline is with pipx.
pipx install memsparkline
You can also use pip:
pip install --user memsparkline
Manual installation
- Install the dependencies from the package repositories of your OS. You will find instructions for some operating systems below.
- Download
memsparkline.py
and copy it to a directory inPATH
asmemsparkline
. For example,
git clone https://gitlab.com/dbohdan/memsparkline
cd memsparkline
sudo install memsparkline.py /usr/local/bin/memsparkline
Dependencies
Debian/Ubuntu
sudo apt install python3-psuti
DragonFly BSD 6.6, FreeBSD 13.1
sudo pkg install py39-psutil
NetBSD 9.3
sudo pkgin in py310-psutil
OpenBSD
doas pkg_add py3-psutil
Usage
usage: memsparkline [-h] [-v] [-d path] [-l n] [-m fmt] [-n] [-o path] [-q]
[-t fmt] [-w ms]
command [arg [arg ...]]
Track the RAM usage (resident set size) of a process and its descendants in
real time.
positional arguments:
command command to run
arg arguments to command
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-d path, --dump path file to which to write full memory usage history when
finished
-l n, --length n sparkline length (default: 20)
-m fmt, --mem-format fmt
format string for memory amounts (default: %0.1f)
-n, --newlines print new sparkline on new line instead of over
previous
-o path, --output path
output file ("-" for standard error)
-q, --quiet do not print sparklines, only final report
-t fmt, --time-format fmt
format string for run time (default: %d:%02d:%04.1f)
-w ms, --wait ms how long to wait between taking samples (default:
1000)
License
MIT.
See also
memusg and spark inspired this project.
Tracking memory usage
- DragonFly BSD, FreeBSD, NetBSD, OpenBSD, and macOS time(1)
-l
flag. - GNU time(1)
-v
flag. - memusg — a Bash script for FreeBSD, Linux, and macOS that measures the peak resident set size of a process.
Sparklines
- spark — a Bash script that generates a Unicode text sparkline from a list of numbers.
- sparkline.tcl — a Tcl script by the developer of this project that does the same. Adds a
--min
and--max
option for setting the scale.
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
Built Distribution
File details
Details for the file memsparkline-0.3.0.tar.gz
.
File metadata
- Download URL: memsparkline-0.3.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 PyPy/7.3.12 Linux/5.19.0-46-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d52c480d4a8f57150c4755587d961ee09dade6068125c196f03870664abd9374 |
|
MD5 | 2f1f2bb6c93ec086f95e418478658856 |
|
BLAKE2b-256 | 94d40e32610992e19e3cf211b4f75d8fd19f1f374488ea80af52e0b9b60ee3c1 |
File details
Details for the file memsparkline-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: memsparkline-0.3.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 PyPy/7.3.12 Linux/5.19.0-46-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2640c16ce4bbb323f5fb0bfb2c1d6d00f71cbf94e8041f7d432ec31ba5e06a12 |
|
MD5 | 15aff1c2a15b01046a9085a6ded53425 |
|
BLAKE2b-256 | bb9b35617f0e1fbf2e9100b1d8f67c994d457296823d55183b2016b4af3375a7 |