TimeIt Resource to easily capture and report time consumed by code snippets.
Project description
timeit_resource
timeit_resource: Python Resource to easily capture and report time consumed by code snippets.
Here is the GitHub repo:
Here is the pip command to install it:
pip install timeit_resource
Here’s a simple example of how you might use timeit_resource:
# Write time elapsed information to stdout, with default title (prefix)
with TimeIt() as timer:
# Your time-consuming code here
for _ in range(1000000):
pass
Here are examples that further explore using timeit_resource:
TimeIt.prefix = ' '
# Write to stdout, nested
with TimeIt("Total time taken"):
from time import sleep
for _ in range(10):
with TimeIt("Time taken - outer"):
for _ in range(10):
with TimeIt("Time taken - inner"):
sleep(0.01)
# Append to output.txt
with TimeIt(title="Time taken", output="output.txt") as t:
# Your time-consuming code here
for _ in range(1000000):
pass
# Write to stderr
with TimeIt(output=sys.stderr) as t:
# Your time-consuming code here
for _ in range(1000000):
pass
# Write to an output stream that the client owns!
with open("output.txt", 'w') as f:
with TimeIt(output=f) as t:
# Your time-consuming code here
for _ in range(1000000):
pass
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
timeit_resource-0.0.1.tar.gz
(6.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 timeit_resource-0.0.1.tar.gz.
File metadata
- Download URL: timeit_resource-0.0.1.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87a57b4622d0cc45e444917df01bfc3afb3705f73906967935907b118d239059
|
|
| MD5 |
7443aa5cc4d35849919e08da390bcbbb
|
|
| BLAKE2b-256 |
60d18e60fc94e8a93b755b1d3e2faf46fc8963096eedceafd2464396115a9aa5
|
File details
Details for the file timeit_resource-0.0.1-py3-none-any.whl.
File metadata
- Download URL: timeit_resource-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6973b67940b53be5e36c8fafd801dd9b3a621ed6dd471e218c9bada7f35acdb9
|
|
| MD5 |
4a9546041a7cfea352ac280ceffc15ef
|
|
| BLAKE2b-256 |
5d43611ad706ad6d05b76975c121b2ba53f1c54b2a0aecbe5bea1a1657de88e1
|