Execute and profile cli commands
Project description
runit
A Python CLI tool to execute, monitor, and profile and visualize commands.
Project Purpose
This project was created to prove that advanced functionality is absolutely possible in the terminal. runit showcases real-time monitoring of child processes, delivers detailed resource reports, and is built with a strong emphasis on robust, well-tested code. The goal: bring a modern, delightful CLI experience to profiling command execution with charts and everything.
License
GPL v3. Please see the LICENSE file in the root of the repo for details.
Features
- Utilizes psutil for advanced resource tracking
- Reports execution time, system resource usage, threads, and child processes (including monitoring of all children)
- Terminal charts displaying CPU and memory usage
- Well tested
Demo
See runit in action:
Requirements
- Python 3.9+
- psutil
- plotext
Installation
Clone this repository and install with pip:
git clone https://github.com/notesofcliff/runit.git
cd runit
python -m venv .venv
source .venv/bin/activate # Or (for Windows) .venv/Scripts/activate
pip install -e .
# Optionally run the tests
python test.py
Or, install directly from GitHub:
pip install git+https://github.com/notesofcliff/runit.git
After installation, use runit to run and analyze any command:
runit [args...] <command>
For example:
runit echo hello world
- If you run
runitwith no arguments, it will print help.
You'll receive a detailed resource usage report.
If plotext is installed and --plot is specified, terminal charts for CPU and memory usage over time will be displayed.
- Charts appear only if the child process runs long enough to gather data.
Example Output
=== runit report ===
Command: ['python', '-c', 'print(123)']
PID: 12345
Start Time: 2025-07-31 12:00:00.000000
End Time: 2025-07-31 12:00:01.000000
Duration: 0:00:01
Max RSS (bytes): 12345678
Max Threads: 4
Max Children: 0
Samples: 10
If plotext is installed, you'll also see beautiful terminal charts for CPU and memory usage.
Run the Benchmarks
To run the benchmarks:
runit python benchmark.py
CLI Options
--log-level LEVEL: Set the logging level (default: INFO)--out-file FILE: Write the report and charts to a file (output is also shown in the terminal)--strip-ansi: Remove ANSI escape codes from output file (for plain text files)--plot: If specified, attempt to plot CPU and memory usagecommand: The command to run and monitor
When using --out-file, the output is both displayed in the terminal and written to the file. For plain text (no colors or terminal formatting), simply add --strip-ansi.
runit --out-file out.txt --strip-ansi python benchmark.py
You'll see the report and charts in your terminal, and a plain text version in out.txt.
Development & Extending
Project Structure
The codebase is organized for clarity and extensibility:
runit/
├── __init__.py
├── cli.py # CLI handling: argparse setup and entrypoint
├── monitor.py # Process launching + stat collection logic
├── report.py # Summary formatter (text output)
├── plotting.py # CPU/memory plots via plotext
├── utils.py # Reusable helpers (ANSI stripping, extractors)
└── logging_config.py # Centralized logging setup
How to Add Features or Extend
- Add new measurements:
- Extend
monitor.pyto collect additional stats. - Add new extractors to
utils.py.
- Extend
- Change reporting:
- Update or add new formatters in
report.py.
- Update or add new formatters in
- Add new CLI options:
- Edit
cli.pyand itscreate_parser()function.
- Edit
- Add/modify plotting:
- Update
plotting.py(plotting is optional and gracefully degrades ifplotextis missing).
- Update
- Logging:
- All modules use a named logger for granular control. Adjust logging config in
logging_config.py. runit --out-file out.txt --strip-ansi python benchmark.py
- All modules use a named logger for granular control. Adjust logging config in
Tips for Contributors
- Each module should do one thing (separation of concerns).
- Avoid global state; keep functions pure where possible.
- Add tests for new features in
test.py. - Use dependency injection for flexibility (e.g., pass formatters or flags).
- Optional features should degrade gracefully (never crash if a dependency is missing).
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file profiler_runit-0.1.4.tar.gz.
File metadata
- Download URL: profiler_runit-0.1.4.tar.gz
- Upload date:
- Size: 101.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5585546ce4d5d2ee2bc6adf8d0d9e91f0064458ece27f8b2b78cbd8743ff8b0
|
|
| MD5 |
7498b258de5970aaa8acf8c478e7dc2d
|
|
| BLAKE2b-256 |
08e2186adf7aaec20c103040115af5a3f26a0e6f4ecf0f1a81ec45fed3ade3e5
|
Provenance
The following attestation bundles were made for profiler_runit-0.1.4.tar.gz:
Publisher:
release.yml on notesofcliff/runit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
profiler_runit-0.1.4.tar.gz -
Subject digest:
a5585546ce4d5d2ee2bc6adf8d0d9e91f0064458ece27f8b2b78cbd8743ff8b0 - Sigstore transparency entry: 501358302
- Sigstore integration time:
-
Permalink:
notesofcliff/runit@14f493e44f80130d2aded89d315c7c00c886d65d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/notesofcliff
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@14f493e44f80130d2aded89d315c7c00c886d65d -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file profiler_runit-0.1.4-py3-none-any.whl.
File metadata
- Download URL: profiler_runit-0.1.4-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a9ebb250e8c8310fda7bfd5fcbfa9b6a02264c255e82d09874828cda10203bf
|
|
| MD5 |
9484023654a2cb82d14864a4fe0009fd
|
|
| BLAKE2b-256 |
7c9d5fef661b92adaa0d59ddaf81bd0f98feac4242500c50d91ed51d5e07dd76
|
Provenance
The following attestation bundles were made for profiler_runit-0.1.4-py3-none-any.whl:
Publisher:
release.yml on notesofcliff/runit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
profiler_runit-0.1.4-py3-none-any.whl -
Subject digest:
7a9ebb250e8c8310fda7bfd5fcbfa9b6a02264c255e82d09874828cda10203bf - Sigstore transparency entry: 501358324
- Sigstore integration time:
-
Permalink:
notesofcliff/runit@14f493e44f80130d2aded89d315c7c00c886d65d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/notesofcliff
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@14f493e44f80130d2aded89d315c7c00c886d65d -
Trigger Event:
workflow_run
-
Statement type: