timer-for-python 0.9.11__tar.gz → 0.9.13__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.
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/PKG-INFO +10 -9
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/README.md +6 -6
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/pyproject.toml +14 -12
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/constant/various.py +2 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/helper/output.py +6 -6
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/helper/time_fractions.py +3 -3
- timer_for_python-0.9.13/src/timer/model/time_fractions.py +40 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/version.py +1 -1
- timer_for_python-0.9.11/src/timer/model/time_fractions.py +0 -30
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/.gitignore +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/LICENSE.md +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/__init__.py +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/conftest.py +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/constant/__init__.py +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/constant/decimals.py +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/controller/__init__.py +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/decorator/__init__.py +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/decorator/function.py +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/error/__init__.py +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/helper/__init__.py +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/helper/decimals.py +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/helper/thread/__init__.py +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/helper/thread/list.py +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/model/__init__.py +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/model/abc/mkdocstrings.py +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/model/elapsed_time_fractions.py +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/model/thread_item.py +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/model/timer.py +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/model/timer_base.py +0 -0
- {timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: timer-for-python
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.13
|
|
4
4
|
Summary: Lightweight package that makes it easy to measure how much time it takes to run Python programs and gauge performance of multiple, smaller bits of code
|
|
5
5
|
Project-URL: Bug Tracker, https://github.com/jakob-bagterp/timer-for-python/issues
|
|
6
6
|
Project-URL: Documentation, https://jakob-bagterp.github.io/timer-for-python/
|
|
@@ -20,17 +20,18 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
21
|
Classifier: Programming Language :: Python :: 3.13
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
23
24
|
Requires-Python: >=3.10
|
|
24
|
-
Requires-Dist: colorist==1.8.
|
|
25
|
+
Requires-Dist: colorist==1.8.15
|
|
25
26
|
Description-Content-Type: text/markdown
|
|
26
27
|
|
|
27
|
-
[](https://github.com/jakob-bagterp/timer-for-python/releases/latest)
|
|
29
|
+
[](https://www.python.org)
|
|
30
|
+
[](https://github.com/jakob-bagterp/timer-for-python/blob/master/LICENSE.md)
|
|
30
31
|
[](https://codecov.io/gh/jakob-bagterp/timer-for-python)
|
|
31
32
|
[](https://github.com/jakob-bagterp/timer-for-python/actions/workflows/github-code-scanning/codeql)
|
|
32
33
|
[](https://github.com/jakob-bagterp/timer-for-python/actions/workflows/test.yml)
|
|
33
|
-
[](https://pepy.tech/project/timer-for-python)
|
|
34
35
|
|
|
35
36
|
# ⏳ Timer for Python ⌛️
|
|
36
37
|
Lightweight Python package that makes it easy to measure how much time it takes to run Python programs and gauge performance of multiple, smaller bits of code.
|
|
@@ -49,7 +50,7 @@ timer.start()
|
|
|
49
50
|
|
|
50
51
|
# Insert your code here
|
|
51
52
|
|
|
52
|
-
timer.stop()
|
|
53
|
+
timer.stop() # Output example: 12.34 seconds
|
|
53
54
|
```
|
|
54
55
|
|
|
55
56
|
#### Context Manager
|
|
@@ -87,7 +88,7 @@ timer.start(decimals=5)
|
|
|
87
88
|
|
|
88
89
|
# Insert your code here
|
|
89
90
|
|
|
90
|
-
timer.stop()
|
|
91
|
+
timer.stop() # Output example: 0.12345 seconds
|
|
91
92
|
```
|
|
92
93
|
|
|
93
94
|
#### Multiple Threads
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
[](https://github.com/jakob-bagterp/timer-for-python/releases/latest)
|
|
2
|
+
[](https://www.python.org)
|
|
3
|
+
[](https://github.com/jakob-bagterp/timer-for-python/blob/master/LICENSE.md)
|
|
4
4
|
[](https://codecov.io/gh/jakob-bagterp/timer-for-python)
|
|
5
5
|
[](https://github.com/jakob-bagterp/timer-for-python/actions/workflows/github-code-scanning/codeql)
|
|
6
6
|
[](https://github.com/jakob-bagterp/timer-for-python/actions/workflows/test.yml)
|
|
7
|
-
[](https://pepy.tech/project/timer-for-python)
|
|
8
8
|
|
|
9
9
|
# ⏳ Timer for Python ⌛️
|
|
10
10
|
Lightweight Python package that makes it easy to measure how much time it takes to run Python programs and gauge performance of multiple, smaller bits of code.
|
|
@@ -23,7 +23,7 @@ timer.start()
|
|
|
23
23
|
|
|
24
24
|
# Insert your code here
|
|
25
25
|
|
|
26
|
-
timer.stop()
|
|
26
|
+
timer.stop() # Output example: 12.34 seconds
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
#### Context Manager
|
|
@@ -61,7 +61,7 @@ timer.start(decimals=5)
|
|
|
61
61
|
|
|
62
62
|
# Insert your code here
|
|
63
63
|
|
|
64
|
-
timer.stop()
|
|
64
|
+
timer.stop() # Output example: 0.12345 seconds
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
#### Multiple Threads
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "timer-for-python"
|
|
3
|
-
version = "0.9.
|
|
3
|
+
version = "0.9.13"
|
|
4
4
|
description = "Lightweight package that makes it easy to measure how much time it takes to run Python programs and gauge performance of multiple, smaller bits of code"
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "Jakob Bagterp", email = "jakob_bagterp@hotmail.com" }
|
|
@@ -19,12 +19,13 @@ classifiers = [
|
|
|
19
19
|
"Programming Language :: Python :: 3.12",
|
|
20
20
|
"Programming Language :: Python :: 3.13",
|
|
21
21
|
"Programming Language :: Python :: 3.14",
|
|
22
|
+
"Programming Language :: Python :: 3.15",
|
|
22
23
|
"License :: OSI Approved :: MIT License",
|
|
23
24
|
"Operating System :: OS Independent",
|
|
24
25
|
]
|
|
25
26
|
|
|
26
27
|
dependencies = [
|
|
27
|
-
"colorist==1.8.
|
|
28
|
+
"colorist==1.8.15",
|
|
28
29
|
]
|
|
29
30
|
|
|
30
31
|
[project.urls]
|
|
@@ -36,24 +37,24 @@ dependencies = [
|
|
|
36
37
|
|
|
37
38
|
[dependency-groups]
|
|
38
39
|
dev = [
|
|
39
|
-
"coverage==7.
|
|
40
|
-
"mypy==2.1
|
|
41
|
-
"pre-commit==4.6.
|
|
42
|
-
"pytest==9.0
|
|
40
|
+
"coverage==7.16.0",
|
|
41
|
+
"mypy==2.4.1",
|
|
42
|
+
"pre-commit==4.6.2",
|
|
43
|
+
"pytest==9.2.0",
|
|
43
44
|
"pytest-cov==7.1.0",
|
|
44
45
|
"pytest-xdist==3.8.0",
|
|
45
|
-
"ruff==0.
|
|
46
|
-
"tox==4.
|
|
46
|
+
"ruff==0.17.3",
|
|
47
|
+
"tox==4.65.0",
|
|
47
48
|
]
|
|
48
49
|
docs = [
|
|
49
50
|
"mkdocs==1.6.1",
|
|
50
|
-
"mkdocs-git-revision-date-localized-plugin==1.
|
|
51
|
-
"mkdocs-material==9.7.
|
|
51
|
+
"mkdocs-git-revision-date-localized-plugin==1.6.2",
|
|
52
|
+
"mkdocs-material==9.7.7",
|
|
52
53
|
"mkdocs-material-extensions==1.3.1",
|
|
53
54
|
"mkdocs-minify-plugin==0.8.0",
|
|
54
55
|
"mkdocs-redirects==1.2.3",
|
|
55
|
-
"mkdocstrings==1.0.
|
|
56
|
-
"mkdocstrings-python==2.0.
|
|
56
|
+
"mkdocstrings==1.0.6",
|
|
57
|
+
"mkdocstrings-python==2.0.9",
|
|
57
58
|
]
|
|
58
59
|
|
|
59
60
|
[build-system]
|
|
@@ -71,6 +72,7 @@ include = ["/src"]
|
|
|
71
72
|
|
|
72
73
|
[tool.uv]
|
|
73
74
|
package = true
|
|
75
|
+
required-version = ">=0.12"
|
|
74
76
|
|
|
75
77
|
[tool.mypy]
|
|
76
78
|
files = ["src"]
|
|
@@ -11,24 +11,24 @@ def message(thread: str, fractions: TimeFractions, decimals: int) -> None:
|
|
|
11
11
|
time = fractions.time
|
|
12
12
|
if time.days > 0:
|
|
13
13
|
# Format: 1d 2h 3m 4s
|
|
14
|
-
print(f"{intro} {time.days}d {time.hours}h {time.minutes}m {fractions.
|
|
14
|
+
print(f"{intro} {time.days}d {time.hours}h {time.minutes}m {fractions.total_seconds_rounded}s{thread_info}")
|
|
15
15
|
elif time.hours > 0:
|
|
16
16
|
# Format: 1h 2m 3s
|
|
17
|
-
print(f"{intro} {time.hours}h {time.minutes}m {fractions.
|
|
17
|
+
print(f"{intro} {time.hours}h {time.minutes}m {fractions.total_seconds_rounded}s{thread_info}")
|
|
18
18
|
elif time.minutes > 0:
|
|
19
19
|
# Format: 62.34 seconds (1m 2s)
|
|
20
20
|
print(
|
|
21
|
-
f"{intro} {fractions.
|
|
21
|
+
f"{intro} {fractions.total_minutes_as_seconds:.{decimals}f} seconds ({time.minutes}m {fractions.total_seconds_rounded}s){thread_info}"
|
|
22
22
|
)
|
|
23
23
|
elif time.seconds > 0:
|
|
24
24
|
# Format: 0.123456789 seconds
|
|
25
|
-
print(f"{intro} {fractions.
|
|
25
|
+
print(f"{intro} {fractions.total_seconds:.{decimals}f} seconds{thread_info}")
|
|
26
26
|
elif time.milliseconds > 0:
|
|
27
27
|
# Format: 123.45 milliseconds
|
|
28
|
-
print(f"{intro} {fractions.
|
|
28
|
+
print(f"{intro} {fractions.total_milliseconds:.{decimals}f} milliseconds{thread_info}")
|
|
29
29
|
elif time.microseconds > 0:
|
|
30
30
|
# Format: 234.56 microseconds
|
|
31
|
-
print(f"{intro} {fractions.
|
|
31
|
+
print(f"{intro} {fractions.total_microseconds:.{decimals}f} microseconds{thread_info}")
|
|
32
32
|
else:
|
|
33
33
|
# Format: 345 nanoseconds
|
|
34
34
|
print(f"{intro} {time.nanoseconds} nanoseconds{thread_info}")
|
|
@@ -4,10 +4,10 @@ from ..model.elapsed_time_fractions import ElapsedTimeFractions
|
|
|
4
4
|
def calculate_time_fractions(elapsed_time_ns: int) -> ElapsedTimeFractions:
|
|
5
5
|
"""Elapsed time is in nanoseconds and should be calculated as difference between start and stop time using on the time.perf_counter_ns() function."""
|
|
6
6
|
|
|
7
|
-
microseconds, nanoseconds = divmod(elapsed_time_ns,
|
|
7
|
+
microseconds, nanoseconds = divmod(elapsed_time_ns, 1_000)
|
|
8
8
|
# As divmod() can be slow, let's return 0s as a tuple if divmod() isn't needed:
|
|
9
|
-
milliseconds, microseconds = divmod(microseconds,
|
|
10
|
-
seconds, milliseconds = divmod(milliseconds,
|
|
9
|
+
milliseconds, microseconds = divmod(microseconds, 1_000) if microseconds > 0 else (0, 0)
|
|
10
|
+
seconds, milliseconds = divmod(milliseconds, 1_000) if milliseconds > 0 else (0, 0)
|
|
11
11
|
minutes, seconds = divmod(seconds, 60) if seconds > 0 else (0, 0)
|
|
12
12
|
hours, minutes = divmod(minutes, 60) if minutes > 0 else (0, 0)
|
|
13
13
|
days, hours = divmod(hours, 24) if hours > 0 else (0, 0)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from .. import helper
|
|
2
|
+
from ..constant.various import SECONDS_PER_MINUTE
|
|
3
|
+
from .elapsed_time_fractions import ElapsedTimeFractions
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TimeFractions:
|
|
7
|
+
__slots__ = ["time"]
|
|
8
|
+
|
|
9
|
+
def __init__(self, elapsed_time_ns: int) -> None:
|
|
10
|
+
self.time: ElapsedTimeFractions = helper.time_fractions.calculate_time_fractions(elapsed_time_ns)
|
|
11
|
+
|
|
12
|
+
@property
|
|
13
|
+
def total_microseconds(self) -> float:
|
|
14
|
+
"""Count the total microseconds and anything below that."""
|
|
15
|
+
|
|
16
|
+
return self.time.microseconds + self.time.nanoseconds / 1_000
|
|
17
|
+
|
|
18
|
+
@property
|
|
19
|
+
def total_milliseconds(self) -> float:
|
|
20
|
+
"""Count the total milliseconds and anything below that. This could potentially be faster by dividing self.microseconds by a 1,000 directly, yet we don't want to lose precision in the decimals."""
|
|
21
|
+
|
|
22
|
+
return self.time.milliseconds + self.total_microseconds / 1_000
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def total_seconds(self) -> float:
|
|
26
|
+
"""Count the total seconds and anything below that. This could potentially be faster by dividing self.milliseconds by a 1,000 directly, yet we don't want to lose precision in the decimals."""
|
|
27
|
+
|
|
28
|
+
return self.time.seconds + self.total_milliseconds / 1_000
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def total_seconds_rounded(self) -> float:
|
|
32
|
+
"""Count the total seconds and anything below that. For instance, if 2 seconds and 567 milliseconds, ensure it'll be rounded up to 3 seconds."""
|
|
33
|
+
|
|
34
|
+
return int(round(self.total_seconds, 0))
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
def total_minutes_as_seconds(self) -> float:
|
|
38
|
+
"""Count the total minutes as seconds and anything below that."""
|
|
39
|
+
|
|
40
|
+
return self.time.minutes * SECONDS_PER_MINUTE + self.total_seconds
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version_info__ = (0, 9,
|
|
1
|
+
__version_info__ = (0, 9, 13)
|
|
2
2
|
__version__ = ".".join(map(str, __version_info__))
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
from .. import helper
|
|
2
|
-
from .elapsed_time_fractions import ElapsedTimeFractions
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class TimeFractions:
|
|
6
|
-
__slots__ = ["time"]
|
|
7
|
-
|
|
8
|
-
def __init__(self, elapsed_time_ns: int) -> None:
|
|
9
|
-
self.time: ElapsedTimeFractions = helper.time_fractions.calculate_time_fractions(elapsed_time_ns)
|
|
10
|
-
|
|
11
|
-
def count_microseconds_to_float(self) -> float:
|
|
12
|
-
return self.time.microseconds + self.time.nanoseconds / 1000
|
|
13
|
-
|
|
14
|
-
def count_milliseconds_to_float(self) -> float:
|
|
15
|
-
"""This could potentially be faster by dividing self.microseconds by a 1000 directly, yet we don't want to lose precision in the decimals."""
|
|
16
|
-
|
|
17
|
-
return self.time.milliseconds + self.count_microseconds_to_float() / 1000
|
|
18
|
-
|
|
19
|
-
def count_seconds_to_float(self) -> float:
|
|
20
|
-
"""This could potentially be faster by dividing self.milliseconds by a 1000 directly, yet we don't want to lose precision in the decimals."""
|
|
21
|
-
|
|
22
|
-
return self.time.seconds + self.count_milliseconds_to_float() / 1000
|
|
23
|
-
|
|
24
|
-
def seconds_rounded(self) -> float:
|
|
25
|
-
"""For instance, if 2 seconds and 567 milliseconds, ensure it'll be rounded up to 3 seconds."""
|
|
26
|
-
|
|
27
|
-
return int(round(self.count_seconds_to_float(), 0))
|
|
28
|
-
|
|
29
|
-
def count_minutes_to_seconds(self) -> float:
|
|
30
|
-
return self.time.minutes * 60 + self.count_seconds_to_float()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{timer_for_python-0.9.11 → timer_for_python-0.9.13}/src/timer/model/elapsed_time_fractions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|