Automatic execution time and memory tracker for Python scripts — works with VSCode, terminal, and every Python runner automatically.
Project description
cntimer ⏱
Automatic execution time and memory tracker for Python scripts.
No code changes. No config. Just pip install cntimer — every script you run will automatically show timing and memory at the end, whether you use VSCode, terminal, or any Python runner.
Install
pip install cntimer
Then run it once to activate auto-tracking:
cntimer your_script.py
From that point on, every plain python your_script.py will show this automatically:
────────────────────────────────────────────────────────────
🕐 Time 1.52 s (cpu: 1.44 s)
📦 Memory 31.2 MB (peak: 62.4 MB)
────────────────────────────────────────────────────────────
✅ Works in base Python, virtual environments (venv), conda, and pipx — no extra steps needed.
How it works
cntimer places a cntimer.pth file into your Python's site-packages directory. Python automatically reads all .pth files on every startup — which is what makes tracking work with zero code changes.
The first time you run cntimer script.py, it silently installs this hook into the active environment (base Python or venv). After that, every python script.py is tracked automatically.
- ✅ Works with VSCode Run button
- ✅ Works in terminal
- ✅ Works in virtual environments (venv, conda, pipx)
- ✅ Works on Windows (x86, x64, ARM64), macOS, Linux
- ✅ No imports needed in your code
Output explained
| Field | Meaning |
|---|---|
| 🕐 Time | Total wall-clock time (how long you waited) |
| cpu | CPU time — excludes sleep, I/O, network wait |
| 📦 Memory | Memory still in use when script finished |
| peak | Highest memory used at any point during execution |
If Time is much bigger than cpu, your script spent time waiting (file I/O, network, sleep).
If they're close, your script is CPU-bound (pure computation).
Manual install (if auto-install failed)
Find your site-packages path:
# Mac / Linux
python3 -c "import site; print(site.getsitepackages()[0])"
# Windows
python -c "import site; print(site.getsitepackages()[0])"
Then copy the file:
macOS
cp cntimer.pth $(python3 -c "import site; print(site.getsitepackages()[0])")/cntimer.pth
Linux
sudo cp cntimer.pth $(python3 -c "import site; print(site.getsitepackages()[0])")/cntimer.pth
Windows 64-bit / ARM64 — run Command Prompt as Administrator
copy cntimer.pth "C:\Program Files\Python3xx\Lib\site-packages\cntimer.pth"
Windows 32-bit — run Command Prompt as Administrator
copy cntimer.pth "C:\Program Files (x86)\Python3xx\Lib\site-packages\cntimer.pth"
Replace
3xxwith your Python version (e.g.312for Python 3.12).
Uninstall
pip uninstall cntimer
Then remove the .pth file:
# Mac / Linux
rm $(python3 -c "import site; print(site.getsitepackages()[0])")/cntimer.pth
# Windows (run as Administrator)
del "C:\Program Files\Python3xx\Lib\site-packages\cntimer.pth"
Changelog
0.1.5
- Fixed auto-tracking in virtual environments (venv, conda, pipx)
cntimer.pthis now self-installed on firstcntimer script.pyrun — no manual steps needed
0.1.4 / 0.1.3
- Added cpu time alongside wall time
- Added peak memory alongside current memory
- Improved cross-platform support (Windows x86, x64, ARM64, macOS, Linux)
License
MIT © 2026 tokitahmidtoufa
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 cntimer-0.1.5.tar.gz.
File metadata
- Download URL: cntimer-0.1.5.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b482c7638881962af1b62526b834c0f5e8527b48f6abe49f2ed58276076fe25
|
|
| MD5 |
905de2b948b49407ca17c54adcb66bf3
|
|
| BLAKE2b-256 |
c41d04e29e7c5071056d6e167196847fef515a7200e9d4e1fc7d3612495c0fc5
|
File details
Details for the file cntimer-0.1.5-py3-none-any.whl.
File metadata
- Download URL: cntimer-0.1.5-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a81adf3feb778c80f5d7097d8813d9cc1c6f1ac486e020e1bd3be550c4ffce8
|
|
| MD5 |
72b420a708511f3d5526b00ab0228945
|
|
| BLAKE2b-256 |
cda0d5f3a61fa987a2e344ddadd6d223551c1c5f33a82b16adf54849795e4758
|