a sssuper simple yet useful tool for you to collct the running time of the codeblock
Project description
PrettyTimer
PrettyTimer is a simple yet useful tool for you to collect the running time of the code blocks.
If you want to evaluate the running time of your code blocks, for example, in a machine learning project, the program has several stages: data load, model forward, gradient backward, etc. Even you will statistic running time more than ten code blocks. The general way is to implement it like this:
import time
start_time_load_data = time.time()
time.sleep(3)
end_time_load_data = time.time()
print(end_time_load_data - start_time_load_data)
start_time_forward = time.time()
time.sleep(3)
end_time_forward = time.time()
print(end_time_forward - start_time_forward)
start_time_backward = time.time()
time.sleep(3)
end_time_backward = time.time()
print(end_time_backward - start_time_backward)
start_time_clloct = time.time()
time.sleep(3)
end_time_clloct = time.time()
print(end_time_clloct - start_time_clloct)
PrettyTimer will reproduce it efficiently and elegantly as follows:
import time
from prettytimer import PrettyTimer
timer = PrettyTimer()
timer.start('load_data')
time.sleep(3)
timer.end('load_data')
timer.start('forward')
time.sleep(3)
timer.end('forward')
timer.start('backward')
time.sleep(3)
timer.end('backward')
timer.start('collect')
time.sleep(3)
timer.end('collect')
timer.collect()
The collected information is a Markdown table style which can be copied and pasted to your Markdown document.
Moreover, Prettytimer provides an ETA (Estimated Time of Arrival) method:
timer.eta(NAME, ITER, TOTAL)
Where NANE is a unique identifier to a timer, ITER is the current iteration and TOTAL is the total iteration of your training schedule.
That's all! Pretty concise, right?
Maybe there is a more graceful way to implement this, if yes, please tell me.
Installation
Install via pip:
pip install -U prettytimer
Install latest development version:
pip install -U git+git@github.com:kinredon/prettytimer.git
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 prettytimer-0.1.dev5.tar.gz.
File metadata
- Download URL: prettytimer-0.1.dev5.tar.gz
- Upload date:
- Size: 61.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2d3accb7162d4c259fa9928501d7f6e23774a048c862b2c4364cf696df53e8c
|
|
| MD5 |
94433ead7ada284fe69580f3254f5a7a
|
|
| BLAKE2b-256 |
7a3d44bb51a877636cb553587af56819eb61e982e557b44b8e7abf2f43190b82
|
File details
Details for the file prettytimer-0.1.dev5-py2.py3-none-any.whl.
File metadata
- Download URL: prettytimer-0.1.dev5-py2.py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bfd003713a3789d90a980378e362188c5001afd53bc22878f9ef8ed06b6431c
|
|
| MD5 |
da2b10b76a8500e7164111f8ab0318e4
|
|
| BLAKE2b-256 |
0c65c5e985672ce562eaca440d46ff1607e161ac54b59939f87760f5b2c791f2
|