precious time
Project description
import prectime
import time
import io
@prectime.function
def request_far_away():
# requesting to server...
time.sleep(3)
response = "Hello!"
return response
response = request_far_away()
# stdout >>> request_far_away - 3.0004s
@prectime.function() # this works too
def request_not_far_away():
# requesting to server...
time.sleep(0.01)
response = "Here!"
return response
@prectime.methods
class BigCalculation(object):
def pi(digits: int):
time.sleep(digits // 100_000)
return
def matrix_mul(a, b):
a_cols = len(a[0])
a_rows = len(a)
b_rows = len(b)
o_n = a_cols * b_rows * a_rows
time.sleep(o_n)
return
pi = BigCalculation.pi(100_000)
# stdout >>> pi - 1.0005s
new_matrix = BigCalculation.matrix_mul([[1, 2], [3, 4]], [[1, 2], [3, 4]])
# stdout >>> matrix_mul - 8.0005s
def tetration(base, height):
n = base
for _ in range(height - 1):
n = base ** n
return n
with prectime.context("big number"):
result = tetration(8, 3)
# stdout >>> big number - 0.3087s
# you can create own class to point (output, round_digits, format)
stream = io.StringIO()
my_measure = prectime.Measure(output=stream,
round_digits=1,
format="{name} --> {time} seconds\n")
with my_measure.context("test"):
time.sleep(0.459)
# stream >>> test --> 0.5 seconds
@prectime.function(stream)
def last_example():
return None and None
last_example()
# stream >>> last_example - 0.0s
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
prectime-0.0.3.tar.gz
(3.5 kB
view details)
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 prectime-0.0.3.tar.gz.
File metadata
- Download URL: prectime-0.0.3.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d625e4bb5aeb397295657f296f1f51f66e8e40161154c445614ab4ba140edc1
|
|
| MD5 |
7ec6b40f58e9b4076fdfeca1e48adca3
|
|
| BLAKE2b-256 |
32655b7eeb16d9c37fc610517ec69ecd56c0f870522a70b68d0f131018604340
|
File details
Details for the file prectime-0.0.3-py3-none-any.whl.
File metadata
- Download URL: prectime-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea325f2905a21b7c64f01ed7adb63fccc327d995311c4874a17602ad319ae50c
|
|
| MD5 |
f30c8c936caf56e58fc94ce69976863b
|
|
| BLAKE2b-256 |
bd3686ad5ef48cf0bb1b05b9a5c18c6867bc6c617e47ace4042295695cf28720
|