timer-for-python 0.9.12__py3-none-any.whl → 0.9.13__py3-none-any.whl

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/constant/various.py CHANGED
@@ -1,2 +1,4 @@
1
1
  NONE_VALUE: str = "NONE"
2
2
  # Note that is has to be an upppercase string to be compatible with the rest of the system.
3
+
4
+ SECONDS_PER_MINUTE = 60
timer/helper/output.py CHANGED
@@ -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.seconds_rounded()}s{thread_info}")
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.seconds_rounded()}s{thread_info}")
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.count_minutes_to_seconds():.{decimals}f} seconds ({time.minutes}m {fractions.seconds_rounded()}s){thread_info}"
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.count_seconds_to_float():.{decimals}f} seconds{thread_info}")
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.count_milliseconds_to_float():.{decimals}f} milliseconds{thread_info}")
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.count_microseconds_to_float():.{decimals}f} microseconds{thread_info}")
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, 1000)
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, 1000) if microseconds > 0 else (0, 0)
10
- seconds, milliseconds = divmod(milliseconds, 1000) if milliseconds > 0 else (0, 0)
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)
@@ -1,4 +1,5 @@
1
1
  from .. import helper
2
+ from ..constant.various import SECONDS_PER_MINUTE
2
3
  from .elapsed_time_fractions import ElapsedTimeFractions
3
4
 
4
5
 
@@ -8,23 +9,32 @@ class TimeFractions:
8
9
  def __init__(self, elapsed_time_ns: int) -> None:
9
10
  self.time: ElapsedTimeFractions = helper.time_fractions.calculate_time_fractions(elapsed_time_ns)
10
11
 
11
- def count_microseconds_to_float(self) -> float:
12
- return self.time.microseconds + self.time.nanoseconds / 1000
12
+ @property
13
+ def total_microseconds(self) -> float:
14
+ """Count the total microseconds and anything below that."""
13
15
 
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
+ return self.time.microseconds + self.time.nanoseconds / 1_000
16
17
 
17
- return self.time.milliseconds + self.count_microseconds_to_float() / 1000
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."""
18
21
 
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."""
22
+ return self.time.milliseconds + self.total_microseconds / 1_000
21
23
 
22
- return self.time.seconds + self.count_milliseconds_to_float() / 1000
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."""
23
27
 
24
- def seconds_rounded(self) -> float:
25
- """For instance, if 2 seconds and 567 milliseconds, ensure it'll be rounded up to 3 seconds."""
28
+ return self.time.seconds + self.total_milliseconds / 1_000
26
29
 
27
- return int(round(self.count_seconds_to_float(), 0))
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."""
28
33
 
29
- def count_minutes_to_seconds(self) -> float:
30
- return self.time.minutes * 60 + self.count_seconds_to_float()
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
timer/version.py CHANGED
@@ -1,2 +1,2 @@
1
- __version_info__ = (0, 9, 12)
1
+ __version_info__ = (0, 9, 13)
2
2
  __version__ = ".".join(map(str, __version_info__))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: timer-for-python
3
- Version: 0.9.12
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.14
25
+ Requires-Dist: colorist==1.8.15
25
26
  Description-Content-Type: text/markdown
26
27
 
27
- [![Latest version](https://img.shields.io/static/v1?label=version&message=0.9.12&color=yellowgreen)](https://github.com/jakob-bagterp/timer-for-python/releases/latest)
28
- [![Python 3.10 | 3.11 | 3.12 | 3.13 | 3.14+](https://img.shields.io/static/v1?label=python&message=3.10%20|%203.11%20|%203.12%20|%203.13%20|%203.14%2B&color=blueviolet)](https://www.python.org)
29
- [![MIT license](https://img.shields.io/static/v1?label=license&message=MIT&color=blue)](https://github.com/jakob-bagterp/timer-for-python/blob/master/LICENSE.md)
28
+ [![Latest version](https://img.shields.io/static/v1?label=Version&message=0.9.13&color=yellowgreen)](https://github.com/jakob-bagterp/timer-for-python/releases/latest)
29
+ [![Python 3.10 | 3.11 | 3.12 | 3.13 | 3.14 | 3.15+](https://img.shields.io/static/v1?label=Python&message=3.10%20|%203.11%20|%203.12%20|%203.13%20|%203.14%20|%203.15%2B&color=blueviolet)](https://www.python.org)
30
+ [![MIT license](https://img.shields.io/static/v1?label=License&message=MIT&color=blue)](https://github.com/jakob-bagterp/timer-for-python/blob/master/LICENSE.md)
30
31
  [![Codecov](https://codecov.io/gh/jakob-bagterp/timer-for-python/branch/master/graph/badge.svg?token=P4IT8WQO0R)](https://codecov.io/gh/jakob-bagterp/timer-for-python)
31
32
  [![CodeQL](https://github.com/jakob-bagterp/timer-for-python/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/jakob-bagterp/timer-for-python/actions/workflows/github-code-scanning/codeql)
32
33
  [![Test](https://github.com/jakob-bagterp/timer-for-python/actions/workflows/test.yml/badge.svg)](https://github.com/jakob-bagterp/timer-for-python/actions/workflows/test.yml)
33
- [![Downloads](https://static.pepy.tech/badge/timer-for-python)](https://pepy.tech/project/timer-for-python)
34
+ [![Downloads](https://api.pepy.tech/personalized-badge/timer-for-python?period=total&units=international_system&left_color=grey&right_color=blue&left_text=Downloads)](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() # Output example: 12.34 seconds
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() # Output example: 0.12345 seconds
91
+ timer.stop() # Output example: 0.12345 seconds
91
92
  ```
92
93
 
93
94
  #### Multiple Threads
@@ -1,28 +1,28 @@
1
1
  timer/__init__.py,sha256=X7Z5wKwhKDIzSnmtYR5Img5iGp13-vfgMWSWGFfHGq4,158
2
2
  timer/conftest.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  timer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- timer/version.py,sha256=3tUtwIesSdCamcyf9Y_kyhQ8wQpPkQtOetG3rm-jUB0,81
4
+ timer/version.py,sha256=n3S-N4BlSg4aqocIBujpKIRAd9OVpt-Bfism_dV0_Cw,81
5
5
  timer/constant/__init__.py,sha256=0e0W-lRc5xtJ9LSsEyq4o6zKckaRweAvrntmFE1gisE,67
6
6
  timer/constant/decimals.py,sha256=9SKe-IbFIbXY-Mps6bSYBqaWuxLiRlsa3rNmT_oDbiM,53
7
- timer/constant/various.py,sha256=v_UX49eVff3JnXs_VgS0luKkCc3iIH_EUalPxNt8-YQ,117
7
+ timer/constant/various.py,sha256=2RLj9vLGk0AKRsdSiNKCtwQplsT_50GY1qvFK_GDKFY,142
8
8
  timer/controller/__init__.py,sha256=lN-rF2nX4pCZ-Z8l7kJTlk4mmsInfLZ52NY4S6Wf6A0,1662
9
9
  timer/decorator/__init__.py,sha256=juqd9PbXs4yg45zMJ7BHAOPQjb7sgEbWE9InBtGZhfo,24
10
10
  timer/decorator/function.py,sha256=LBbtkIA9p1T-HgIh6OMgtJTyOmo6aM5TuIwK0E7ieQk,3570
11
11
  timer/error/__init__.py,sha256=pjjCgDtv2TJ8-eBnq98buWPIDt-Znfj1Gbk9CXzJhQE,1197
12
12
  timer/helper/__init__.py,sha256=kYe7PVpjG7UeamvAvohgiIleefsGslx1tJvuNO5_oSQ,117
13
13
  timer/helper/decimals.py,sha256=3WXpSLkf8ySbOMgE98ieTvs1ILaSA1ymennlQdMxaNM,1629
14
- timer/helper/output.py,sha256=doWzg3W4fKA5udxrKl1RJkMrqqDyzh3FR9kL-4i13VE,1744
15
- timer/helper/time_fractions.py,sha256=sDz-ZOnMC6shJKiMCBc_oYk3kMjyNklYmoU4kbQMh-8,1089
14
+ timer/helper/output.py,sha256=i2CDkKAncKrLormmOScWQPcBnysNdslJpwRNDIVQjak,1721
15
+ timer/helper/time_fractions.py,sha256=nlLUf-ni1osDhG9IzGmlZz_m07hTBXF3tC394v5e0Po,1092
16
16
  timer/helper/thread/__init__.py,sha256=sIXJTI05fLVUT71DbiBf0axFpxOn0L9sRe23KUOC8Gw,471
17
17
  timer/helper/thread/list.py,sha256=6rT-0zRG9xuwbQsLpFdTeoa-O1NqWiCbznzsC31e2SA,1485
18
18
  timer/model/__init__.py,sha256=m-K3jgLBqKUwBNJByKeLiGQCzCVZC07N12_SmkbGxyg,145
19
19
  timer/model/elapsed_time_fractions.py,sha256=UXfABMQ14kgsEHjQmef2PKMgtdqKF9zPyrmA9_TQHrg,282
20
20
  timer/model/thread_item.py,sha256=7i7oH2eghF5K_k4Oed-i6to85VoPlJw3_g0U5ilB_VY,199
21
- timer/model/time_fractions.py,sha256=yweResJFS7NutBoLWZYKC1f7GIemwWVIiEc04xsxOno,1298
21
+ timer/model/time_fractions.py,sha256=IRUgEwGMD18A4kjCoO9vvn60FUNXxnqhK7IWeSTMPJc,1670
22
22
  timer/model/timer.py,sha256=cQblVIvhIU-Fhh3L4EvYVZNFkNWj8ABv1A1detaQMGo,7190
23
23
  timer/model/timer_base.py,sha256=TZ_ROsJWM0hLioXnYTFv_WMqN31c1i2yng2IU8vteWc,1015
24
24
  timer/model/abc/mkdocstrings.py,sha256=3JrQVkW0D4YW7hOVOr9Jd35gH7-Z5o8y0bNjQz1EAzw,350
25
- timer_for_python-0.9.12.dist-info/METADATA,sha256=wp-H1yXL0U-oRjaawurVas37BXOTCCMI5RKJUQ-Qt3w,5827
26
- timer_for_python-0.9.12.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
27
- timer_for_python-0.9.12.dist-info/licenses/LICENSE.md,sha256=bV6mZhoYf6kHYGgsG3ArjpF_tjOweaI7QZKRvmzkUMI,1085
28
- timer_for_python-0.9.12.dist-info/RECORD,,
25
+ timer_for_python-0.9.13.dist-info/METADATA,sha256=ySQNaGia3y0bq8XtX4R7V_fbBtPJSluInQjBM8AvUVo,6001
26
+ timer_for_python-0.9.13.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
27
+ timer_for_python-0.9.13.dist-info/licenses/LICENSE.md,sha256=bV6mZhoYf6kHYGgsG3ArjpF_tjOweaI7QZKRvmzkUMI,1085
28
+ timer_for_python-0.9.13.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.32.0
2
+ Generator: hatchling 1.33.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any