cntimer 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cntimer-0.1.0/LICENSE +21 -0
- cntimer-0.1.0/PKG-INFO +73 -0
- cntimer-0.1.0/README.md +47 -0
- cntimer-0.1.0/cntimer/__init__.py +7 -0
- cntimer-0.1.0/cntimer/runner.py +96 -0
- cntimer-0.1.0/cntimer.egg-info/PKG-INFO +73 -0
- cntimer-0.1.0/cntimer.egg-info/SOURCES.txt +10 -0
- cntimer-0.1.0/cntimer.egg-info/dependency_links.txt +1 -0
- cntimer-0.1.0/cntimer.egg-info/entry_points.txt +2 -0
- cntimer-0.1.0/cntimer.egg-info/top_level.txt +1 -0
- cntimer-0.1.0/pyproject.toml +41 -0
- cntimer-0.1.0/setup.cfg +4 -0
cntimer-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tokit Ahmid Toufa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
cntimer-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cntimer
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Run Python scripts and see execution time + memory usage in your terminal
|
|
5
|
+
Author: Tokit Ahmid Toufa
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/yourusername/cntimer
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/yourusername/cntimer/issues
|
|
9
|
+
Keywords: timer,memory,performance,terminal,runner,stats,profiler,cli
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: Utilities
|
|
21
|
+
Classifier: Environment :: Console
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# cntimer ⏱️
|
|
28
|
+
|
|
29
|
+
Run any Python script and instantly see **execution time + memory usage** in your terminal.
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install cntimer
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
cntimer myscript.py
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Output:
|
|
42
|
+
```
|
|
43
|
+
hello world
|
|
44
|
+
|
|
45
|
+
────────────────────────────────────────────────────────────
|
|
46
|
+
🕐 Time 21.4 ms (cpu: 20.9 ms)
|
|
47
|
+
📦 Memory 96 KB (peak: 19.0 MB)
|
|
48
|
+
────────────────────────────────────────────────────────────
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Pass arguments to your script too:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
cntimer myscript.py arg1 arg2
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## What the stats mean
|
|
58
|
+
|
|
59
|
+
| Stat | Meaning |
|
|
60
|
+
|------|---------|
|
|
61
|
+
| **Time** | Total real-world clock time |
|
|
62
|
+
| **cpu** | Actual CPU processing time (excludes I/O wait) |
|
|
63
|
+
| **Memory** | Memory in use when the script finished |
|
|
64
|
+
| **peak** | Maximum memory used during the entire run |
|
|
65
|
+
|
|
66
|
+
## Requirements
|
|
67
|
+
|
|
68
|
+
- Python 3.8+
|
|
69
|
+
- No external dependencies — uses only the standard library ✅
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT
|
cntimer-0.1.0/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# cntimer ⏱️
|
|
2
|
+
|
|
3
|
+
Run any Python script and instantly see **execution time + memory usage** in your terminal.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install cntimer
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
cntimer myscript.py
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Output:
|
|
16
|
+
```
|
|
17
|
+
hello world
|
|
18
|
+
|
|
19
|
+
────────────────────────────────────────────────────────────
|
|
20
|
+
🕐 Time 21.4 ms (cpu: 20.9 ms)
|
|
21
|
+
📦 Memory 96 KB (peak: 19.0 MB)
|
|
22
|
+
────────────────────────────────────────────────────────────
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Pass arguments to your script too:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
cntimer myscript.py arg1 arg2
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## What the stats mean
|
|
32
|
+
|
|
33
|
+
| Stat | Meaning |
|
|
34
|
+
|------|---------|
|
|
35
|
+
| **Time** | Total real-world clock time |
|
|
36
|
+
| **cpu** | Actual CPU processing time (excludes I/O wait) |
|
|
37
|
+
| **Memory** | Memory in use when the script finished |
|
|
38
|
+
| **peak** | Maximum memory used during the entire run |
|
|
39
|
+
|
|
40
|
+
## Requirements
|
|
41
|
+
|
|
42
|
+
- Python 3.8+
|
|
43
|
+
- No external dependencies — uses only the standard library ✅
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
MIT
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import subprocess
|
|
2
|
+
import sys
|
|
3
|
+
import time
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def _format_time(seconds: float) -> str:
|
|
8
|
+
if seconds < 1:
|
|
9
|
+
return f"{seconds * 1000:.1f} ms"
|
|
10
|
+
return f"{seconds:.3f} s"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _format_memory(bytes_val: int) -> str:
|
|
14
|
+
if bytes_val < 1024:
|
|
15
|
+
return f"{bytes_val} B"
|
|
16
|
+
elif bytes_val < 1024 * 1024:
|
|
17
|
+
return f"{bytes_val / 1024:.1f} KB"
|
|
18
|
+
else:
|
|
19
|
+
return f"{bytes_val / (1024 * 1024):.1f} MB"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _print_stats(wall_time: float, cpu_time: float, mem_current: int, mem_peak: int) -> None:
|
|
23
|
+
sep = "─" * 60
|
|
24
|
+
time_str = _format_time(wall_time)
|
|
25
|
+
cpu_str = _format_time(cpu_time)
|
|
26
|
+
mem_str = _format_memory(mem_current)
|
|
27
|
+
peak_str = _format_memory(mem_peak)
|
|
28
|
+
|
|
29
|
+
RESET = "\033[0m"
|
|
30
|
+
YELLOW = "\033[93m"
|
|
31
|
+
BLUE = "\033[94m"
|
|
32
|
+
DIM = "\033[2m"
|
|
33
|
+
|
|
34
|
+
print(f"\n{DIM}{sep}{RESET}")
|
|
35
|
+
print(f" {BLUE}🕐 Time {RESET}{YELLOW}{time_str:<12}{RESET} {DIM}(cpu: {cpu_str}){RESET}")
|
|
36
|
+
print(f" {BLUE}📦 Memory {RESET}{YELLOW}{mem_str:<12}{RESET} {DIM}(peak: {peak_str}){RESET}")
|
|
37
|
+
print(f"{DIM}{sep}{RESET}\n")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def run() -> None:
|
|
41
|
+
import argparse
|
|
42
|
+
|
|
43
|
+
parser = argparse.ArgumentParser(
|
|
44
|
+
prog="cntimer",
|
|
45
|
+
description="Run a Python script and display execution time + memory usage."
|
|
46
|
+
)
|
|
47
|
+
parser.add_argument("script", help="Path to the Python script to run")
|
|
48
|
+
parser.add_argument("args", nargs=argparse.REMAINDER, help="Arguments to pass to the script")
|
|
49
|
+
args = parser.parse_args()
|
|
50
|
+
|
|
51
|
+
script = args.script
|
|
52
|
+
script_args = args.args
|
|
53
|
+
|
|
54
|
+
if not os.path.exists(script):
|
|
55
|
+
print(f"❌ File not found: {script}", file=sys.stderr)
|
|
56
|
+
sys.exit(1)
|
|
57
|
+
|
|
58
|
+
wrapper = (
|
|
59
|
+
"import tracemalloc, runpy, sys\n"
|
|
60
|
+
"tracemalloc.start()\n"
|
|
61
|
+
"try:\n"
|
|
62
|
+
" runpy.run_path(sys.argv[1], run_name='__main__')\n"
|
|
63
|
+
"except SystemExit:\n"
|
|
64
|
+
" pass\n"
|
|
65
|
+
"current, peak = tracemalloc.get_traced_memory()\n"
|
|
66
|
+
"tracemalloc.stop()\n"
|
|
67
|
+
"with open('/tmp/_cntimer_mem.txt', 'w') as f:\n"
|
|
68
|
+
" f.write(f'{current},{peak}')\n"
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
start_wall = time.perf_counter()
|
|
72
|
+
start_cpu = time.process_time()
|
|
73
|
+
|
|
74
|
+
result = subprocess.run(
|
|
75
|
+
[sys.executable, "-c", wrapper, script] + script_args,
|
|
76
|
+
text=True
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
end_wall = time.perf_counter()
|
|
80
|
+
end_cpu = time.process_time()
|
|
81
|
+
|
|
82
|
+
wall_time = end_wall - start_wall
|
|
83
|
+
cpu_time = end_cpu - start_cpu
|
|
84
|
+
|
|
85
|
+
mem_current, mem_peak = 0, 0
|
|
86
|
+
try:
|
|
87
|
+
with open("/tmp/_cntimer_mem.txt", "r") as f:
|
|
88
|
+
parts = f.read().strip().split(",")
|
|
89
|
+
mem_current = int(parts[0])
|
|
90
|
+
mem_peak = int(parts[1])
|
|
91
|
+
os.remove("/tmp/_cntimer_mem.txt")
|
|
92
|
+
except Exception:
|
|
93
|
+
pass
|
|
94
|
+
|
|
95
|
+
_print_stats(wall_time, cpu_time, mem_current, mem_peak)
|
|
96
|
+
sys.exit(result.returncode)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cntimer
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Run Python scripts and see execution time + memory usage in your terminal
|
|
5
|
+
Author: Tokit Ahmid Toufa
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/yourusername/cntimer
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/yourusername/cntimer/issues
|
|
9
|
+
Keywords: timer,memory,performance,terminal,runner,stats,profiler,cli
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: Utilities
|
|
21
|
+
Classifier: Environment :: Console
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# cntimer ⏱️
|
|
28
|
+
|
|
29
|
+
Run any Python script and instantly see **execution time + memory usage** in your terminal.
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install cntimer
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
cntimer myscript.py
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Output:
|
|
42
|
+
```
|
|
43
|
+
hello world
|
|
44
|
+
|
|
45
|
+
────────────────────────────────────────────────────────────
|
|
46
|
+
🕐 Time 21.4 ms (cpu: 20.9 ms)
|
|
47
|
+
📦 Memory 96 KB (peak: 19.0 MB)
|
|
48
|
+
────────────────────────────────────────────────────────────
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Pass arguments to your script too:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
cntimer myscript.py arg1 arg2
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## What the stats mean
|
|
58
|
+
|
|
59
|
+
| Stat | Meaning |
|
|
60
|
+
|------|---------|
|
|
61
|
+
| **Time** | Total real-world clock time |
|
|
62
|
+
| **cpu** | Actual CPU processing time (excludes I/O wait) |
|
|
63
|
+
| **Memory** | Memory in use when the script finished |
|
|
64
|
+
| **peak** | Maximum memory used during the entire run |
|
|
65
|
+
|
|
66
|
+
## Requirements
|
|
67
|
+
|
|
68
|
+
- Python 3.8+
|
|
69
|
+
- No external dependencies — uses only the standard library ✅
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cntimer
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "cntimer"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Run Python scripts and see execution time + memory usage in your terminal"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "Tokit Ahmid Toufa" }
|
|
13
|
+
]
|
|
14
|
+
keywords = ["timer", "memory", "performance", "terminal", "runner", "stats", "profiler", "cli"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.8",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
26
|
+
"Topic :: Utilities",
|
|
27
|
+
"Environment :: Console",
|
|
28
|
+
]
|
|
29
|
+
requires-python = ">=3.8"
|
|
30
|
+
dependencies = []
|
|
31
|
+
|
|
32
|
+
[project.scripts]
|
|
33
|
+
cntimer = "cntimer.runner:run"
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://github.com/yourusername/cntimer"
|
|
37
|
+
"Bug Tracker" = "https://github.com/yourusername/cntimer/issues"
|
|
38
|
+
|
|
39
|
+
[tool.setuptools.packages.find]
|
|
40
|
+
where = ["."]
|
|
41
|
+
include = ["cntimer*"]
|
cntimer-0.1.0/setup.cfg
ADDED