https://github.com/raymondbutcher/python-timeprint
Python context manager and decorator for showing time elapsed
https://github.com/raymondbutcher/python-timeprint
python python-3
Last synced: over 1 year ago
JSON representation
Python context manager and decorator for showing time elapsed
- Host: GitHub
- URL: https://github.com/raymondbutcher/python-timeprint
- Owner: raymondbutcher
- License: mit
- Created: 2017-02-25T18:09:16.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-01T22:27:01.000Z (over 9 years ago)
- Last Synced: 2025-02-26T00:02:55.567Z (over 1 year ago)
- Topics: python, python-3
- Language: Python
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Timeprint
Python context manager and decorator for showing time elapsed.
# Setup
```
pip install timeprint
```
# Usage as a context manager
```python
import timeprint
with timeprint:
do_stuff()
# it took 100ms
with timeprint('some stuff')
do_stuff()
# some stuff took 100ms
```
# Usage as a decorator
```python
import timeprint
@timeprint
def first_function():
do_stuff()
# first_function took 100ms
@timeprint('some other stuff')
def second_function():
do_stuff()
# some other stuff took 100ms
```
# Is that it?
Yes. I was tired of finding and copying my old [Gist](https://gist.github.com/raymondbutcher/5168588) into files every time I wanted to measure a small chunk of code.